GeezerVison is showing github.com — make_class -> make_static_type by youknowone · Pull Request #7331 · RustPython/RustPython
Conversation
youknowone
commented
Mar 3, 2026
•
edited by coderabbitai
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
Summary by CodeRabbit
- Refactor
- Streamlined internal type system architecture across multiple modules to improve code organization and consistency.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
coderabbitai
Bot
commented
Mar 3, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between be0c3ca and 0b51d3b.
📒 Files selected for processing (10)
crates/derive-impl/src/pymodule.rs
crates/stdlib/src/select.rs
crates/vm/src/class.rs
crates/vm/src/stdlib/ast.rs
crates/vm/src/stdlib/ast/pyast.rs
crates/vm/src/stdlib/ast/python.rs
crates/vm/src/stdlib/ast/repr.rs
crates/vm/src/stdlib/builtins.rs
crates/vm/src/stdlib/ctypes.rs
crates/wasm/src/browser_module.rs
📝 Walkthrough
Walkthrough
This PR systematically refactors the PyClassImpl trait API across the RustPython codebase, replacing the context-dependent make_class(ctx) method with a static make_static_type() method. The core change removes the requirement to pass a Context parameter at call sites, instead using Context::genesis() internally. This affects class registration in the derive macro, AST module, ctypes module, select module, and WASM browser module.
Changes
| Cohort / File(s) |
Summary |
Core PyClassImpl Refactoring crates/vm/src/class.rs |
Updated the PyClassImpl trait method signature from make_class(ctx: &Context) -> PyTypeRef to make_static_type() -> PyTypeRef, removing context parameter dependency and using Context::genesis() internally. |
Macro-Generated Code crates/derive-impl/src/pymodule.rs |
Updated code generation for #[pyclass] and #[pystruct_sequence] to call make_static_type() instead of make_class(ctx) when creating class instances. |
Select Module crates/stdlib/src/select.rs |
Replaced PyPoll::make_class(&vm.ctx) with PyPoll::make_static_type() in module initialization and updated the epoll() function signature to use the static type constructor. |
AST Module Initialization crates/vm/src/stdlib/ast.rs |
Refactored mode_type_and_name() function signature from mode_type_and_name(ctx: &Context, mode: &str) to mode_type_and_name(mode: &str), using static type constructors internally for AST mode variants. |
AST Node Registrations crates/vm/src/stdlib/ast/pyast.rs |
Systematically replaced all 126+ node type registrations from NodeType::make_class(&vm.ctx) to NodeType::make_static_type() across the complete AST node hierarchy (e.g., Module, FunctionDef, ClassDef, expr nodes, etc.). |
AST Type Access crates/vm/src/stdlib/ast/python.rs, crates/vm/src/stdlib/ast/repr.rs |
Updated type checks and access patterns to use make_static_type() instead of make_class(ctx) for NodeExprContext and NodeAst type comparisons. |
Builtins Module crates/vm/src/stdlib/builtins.rs |
Changed compile function and module initialization to use make_static_type() for VecBuffer and ast::NodeAst, and updated mode_type_and_name() call to remove context parameter. |
Ctypes Module crates/vm/src/stdlib/ctypes.rs |
Replaced make_class(ctx) with make_static_type() for 7+ ctypes type constructors (PyCSimpleType, PyCArrayType, PyCPointerType, etc.) and updated all public module export mappings. |
WASM Browser Module crates/wasm/src/browser_module.rs |
Updated Document type exposure to use make_static_type() instead of make_class(&vm.ctx). |
Estimated code review effort
🎯 3 (Moderate) | ⏱️ ~25 minutes
Possibly related PRs
Suggested reviewers
Poem
🐰 Hops with delight through static dreams,
Where context flows through genesis streams,
No parameters passed, just types so bright,
Classes born static in the module's light!
🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
| Check name |
Status |
Explanation |
Resolution |
| Docstring Coverage |
⚠️ Warning |
Docstring coverage is 35.29% which is insufficient. The required threshold is 80.00%. |
Write docstrings for the functions missing them to satisfy the coverage threshold. |
✅ Passed checks (2 passed)
| Check name |
Status |
Explanation |
| Description Check |
✅ Passed |
Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title check |
✅ Passed |
The title directly and clearly describes the main change: a systematic replacement of make_class calls with make_static_type across the codebase. |
✏️ Tip: You can configure your own custom pre-merge checks in the settings.
✨ Finishing Touches
🧪 Generate unit tests (beta)
- Create PR with unit tests
- Post copyable unit tests in a comment
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share
Comment @coderabbitai help to get the list of available commands and usage tips.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Use Context::genesis() directly in make_class to obtain
&'static Context, eliminating the raw pointer cast.
Uh oh!
There was an error while loading. Please reload this page.
youknowone
added a commit
to youknowone/RustPython
that referenced
this pull request
Mar 22, 2026
* Remove unsafe ctx cast in make_class
Use Context::genesis() directly in make_class to obtain
&'static Context, eliminating the raw pointer cast.
* make_class -> make_static_type
youknowone
added a commit
that referenced
this pull request
Sep 16, 2026
* Remove unsafe ctx cast in make_class
Use Context::genesis() directly in make_class to obtain
&'static Context, eliminating the raw pointer cast.
* make_class -> make_static_type
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|