GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — make_class -> make_static_type by youknowone · Pull Request #7331 · RustPython/RustPython

Conversation

@youknowone

@youknowone youknowone commented Mar 3, 2026 •
edited by coderabbitai Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

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.

All reactions
@coderabbitai

coderabbitai Bot commented Mar 3, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

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

  • extend types and exceptions only for genesis #7316: Directly related refactoring of the same PyClassImpl trait API and Context lifetime surface across crates/vm/src/class.rs and crates/derive-impl/.
  • Update _ast_unparse and fix unparse, type_comments #6961: Extends the AST module APIs being refactored in this PR, including modifications to mode_type_and_name() and AST node type registrations.

Suggested reviewers

  • arihant2math

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
  • X
  • Mastodon
  • Reddit
  • LinkedIn

Comment @coderabbitai help to get the list of available commands and usage tips.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

youknowone added 2 commits March 3, 2026 23:53
@youknowone
Remove unsafe ctx cast in make_class
a16cd83
Use Context::genesis() directly in make_class to obtain
&'static Context, eliminating the raw pointer cast.
@youknowone
make_class -> make_static_type
0b51d3b
@youknowone
youknowone force-pushed the make-class branch from 7b93d2c to 0b51d3b Compare March 3, 2026 14:53
@youknowone
youknowone marked this pull request as ready for review March 3, 2026 16:23
@youknowone
youknowone merged commit 9b9c749 into RustPython:main Mar 3, 2026
23 of 24 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@youknowone
youknowone deleted the make-class branch March 3, 2026 19:28
youknowone added a commit to youknowone/RustPython that referenced this pull request Mar 22, 2026
@youknowone
make_class -> make_static_type (RustPython#7331)
f779fa5
* 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
@youknowone
make_class -> make_static_type (#7331)
86bdd4b
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

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.

1 participant

@youknowone
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.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.