GeezerVison is showing github.com — Rename stdlib files to match Python module names by youknowone · Pull Request #7397 · RustPython/RustPython
Conversation
youknowone
commented
Mar 10, 2026
•
edited by coderabbitai
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
Add _ prefix to source files whose Python module names start with _: ast→_ast, codecs→_codecs, collections→_collections, ctypes→_ctypes, functools→_functools, imp→_imp, io→_io, operator→_operator, signal→_signal, sre→_sre, stat→_stat, string→_string, symtable→_symtable, sysconfig→_sysconfig, sysconfigdata→_sysconfigdata, thread→_thread, typing→_typing, warnings→_warnings, weakref→_weakref.
Update mod.rs and all cross-crate references accordingly.
Summary by CodeRabbit
- Refactor
- Internal reorganization of standard library module structure with no user-facing impact on functionality or APIs.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
coderabbitai
Bot
commented
Mar 10, 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
⚙️ Run configuration
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
Run ID: 5a4dff2d-803e-4fcd-8168-e88ff6a92591
📥 Commits
Reviewing files that changed from the base of the PR and between 0355885 and 50c19ba.
📒 Files selected for processing (72)
crates/stdlib/src/array.rs
crates/stdlib/src/faulthandler.rs
crates/stdlib/src/fcntl.rs
crates/stdlib/src/select.rs
crates/stdlib/src/ssl.rs
crates/vm/src/builtins/complex.rs
crates/vm/src/builtins/genericalias.rs
crates/vm/src/builtins/tuple.rs
crates/vm/src/builtins/union.rs
crates/vm/src/frame.rs
crates/vm/src/ospath.rs
crates/vm/src/protocol/number.rs
crates/vm/src/signal.rs
crates/vm/src/stdlib/_ast.rs
crates/vm/src/stdlib/_ast/argument.rs
crates/vm/src/stdlib/_ast/basic.rs
crates/vm/src/stdlib/_ast/constant.rs
crates/vm/src/stdlib/_ast/elif_else_clause.rs
crates/vm/src/stdlib/_ast/exception.rs
crates/vm/src/stdlib/_ast/expression.rs
crates/vm/src/stdlib/_ast/module.rs
crates/vm/src/stdlib/_ast/node.rs
crates/vm/src/stdlib/_ast/operator.rs
crates/vm/src/stdlib/_ast/other.rs
crates/vm/src/stdlib/_ast/parameter.rs
crates/vm/src/stdlib/_ast/pattern.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/_ast/statement.rs
crates/vm/src/stdlib/_ast/string.rs
crates/vm/src/stdlib/_ast/type_ignore.rs
crates/vm/src/stdlib/_ast/type_parameters.rs
crates/vm/src/stdlib/_ast/validate.rs
crates/vm/src/stdlib/_codecs.rs
crates/vm/src/stdlib/_collections.rs
crates/vm/src/stdlib/_ctypes.rs
crates/vm/src/stdlib/_ctypes/array.rs
crates/vm/src/stdlib/_ctypes/base.rs
crates/vm/src/stdlib/_ctypes/function.rs
crates/vm/src/stdlib/_ctypes/library.rs
crates/vm/src/stdlib/_ctypes/pointer.rs
crates/vm/src/stdlib/_ctypes/simple.rs
crates/vm/src/stdlib/_ctypes/structure.rs
crates/vm/src/stdlib/_ctypes/union.rs
crates/vm/src/stdlib/_functools.rs
crates/vm/src/stdlib/_imp.rs
crates/vm/src/stdlib/_io.rs
crates/vm/src/stdlib/_operator.rs
crates/vm/src/stdlib/_signal.rs
crates/vm/src/stdlib/_sre.rs
crates/vm/src/stdlib/_stat.rs
crates/vm/src/stdlib/_string.rs
crates/vm/src/stdlib/_symtable.rs
crates/vm/src/stdlib/_sysconfig.rs
crates/vm/src/stdlib/_sysconfigdata.rs
crates/vm/src/stdlib/_thread.rs
crates/vm/src/stdlib/_typing.rs
crates/vm/src/stdlib/_warnings.rs
crates/vm/src/stdlib/_weakref.rs
crates/vm/src/stdlib/_winapi.rs
crates/vm/src/stdlib/builtins.rs
crates/vm/src/stdlib/mod.rs
crates/vm/src/stdlib/os.rs
crates/vm/src/stdlib/posix.rs
crates/vm/src/stdlib/sys.rs
crates/vm/src/stdlib/typevar.rs
crates/vm/src/types/zoo.rs
crates/vm/src/vm/context.rs
crates/vm/src/vm/mod.rs
crates/vm/src/vm/thread.rs
crates/vm/src/vm/vm_ops.rs
📝 Walkthrough
Walkthrough
This pull request systematically renames internal stdlib modules by adding underscore prefixes (e.g., ast → _ast, typing → _typing, warnings → _warnings). All corresponding import paths and call sites throughout the codebase are updated consistently to reference the new underscore-prefixed module paths.
Changes
| Cohort / File(s) |
Summary |
Module Declaration Reorganization crates/vm/src/stdlib/mod.rs |
Renamed and re-exported stdlib modules with underscore prefixes (ast→_ast, io→_io, typing→_typing, warnings→_warnings, thread→_thread, signal→_signal, ctypes→_ctypes, and 10+ others). Updated builtin_module_defs registrations to reference underscore-prefixed module definitions. |
Warnings Module Refactoring crates/stdlib/src/array.rs, crates/stdlib/src/ssl.rs, crates/vm/src/builtins/complex.rs, crates/vm/src/stdlib/_ctypes/structure.rs, crates/vm/src/stdlib/_ctypes/union.rs, crates/vm/src/stdlib/_io.rs, crates/vm/src/stdlib/os.rs, crates/vm/src/stdlib/posix.rs, crates/vm/src/stdlib/sys.rs, crates/vm/src/vm/vm_ops.rs |
Replaced stdlib::warnings with stdlib::_warnings in import paths and updated warn() call sites to use the new internal warnings path. |
Thread Module Migration crates/stdlib/src/faulthandler.rs, crates/vm/src/_imp.rs, crates/vm/src/_winapi.rs, crates/vm/src/stdlib/mod.rs, crates/vm/src/stdlib/posix.rs, crates/vm/src/stdlib/sys.rs, crates/vm/src/vm/mod.rs, crates/vm/src/vm/thread.rs |
Updated all thread-related imports and function calls from stdlib::thread to stdlib::_thread (e.g., get_ident(), get_all_current_frames(), CurrentFrameSlot, HandleEntry). |
IO Module Path Updates crates/stdlib/src/fcntl.rs, crates/stdlib/src/select.rs, crates/vm/src/stdlib/mod.rs, crates/vm/src/stdlib/posix.rs, crates/vm/src/vm/mod.rs |
Replaced references to stdlib::io with stdlib::_io including type usages (Fildes, OpenArgs) and function calls (open()). |
Typing Module Migration crates/vm/src/builtins/genericalias.rs, crates/vm/src/builtins/union.rs, crates/vm/src/frame.rs, crates/vm/src/stdlib/typevar.rs, crates/vm/src/types/zoo.rs, crates/vm/src/vm/context.rs |
Updated all typing-related imports and constructors from stdlib::typing to stdlib::_typing, including TypeVar, ParamSpec, TypeVarTuple, TypeAliasType, and NoDefault references. |
AST Module Relocation crates/vm/src/builtins/genericalias.rs, crates/vm/src/stdlib/_ast.rs, crates/vm/src/stdlib/_ast/expression.rs, crates/vm/src/stdlib/_ast/module.rs, crates/vm/src/stdlib/_ast/python.rs, crates/vm/src/stdlib/_ast/repr.rs, crates/vm/src/stdlib/_ast/statement.rs, crates/vm/src/stdlib/builtins.rs |
Systematically updated AST module imports from stdlib::ast to stdlib::_ast across all AST-related code, including NodeAst, mode types, and validation functions. |
Signal Module Path Update crates/vm/src/signal.rs, crates/vm/src/stdlib/posix.rs |
Updated internal signal module path from stdlib::signal::_signal to stdlib::_signal::_signal and related references. |
Minor Formatting crates/vm/src/builtins/tuple.rs |
Reflowed multi-line field access in freelist_len calculation without behavioral changes. |
Estimated code review effort
🎯 3 (Moderate) | ⏱️ ~25 minutes
Possibly related PRs
- Refactor warn.rs and _warnings module #7023: Refactors the warnings API with updated signature that returns
PyResult and accepts vm parameter, which this PR adapts to throughout the codebase.
- initial sandbox #7035: Modifies stdlib module declarations and
module_def wiring, intersecting with the module reorganization and feature-gating changes in mod.rs.
- Refactor _ast module for clarity #7031: Refactors AST module internals and APIs, directly related to the systematic
ast → _ast migration across the codebase.
Suggested reviewers
- ShaharNaveh
- fanninpm
- coolreader18
Poem
🐰 A rabbit's ode to module names
With underscores bold, the modules now hide,
From public sight, yet steady provide,
Internal pathways, cleaner and clean,
The finest refactor this rabbit has seen! ✨
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
| Check name |
Status |
Explanation |
| Description Check |
✅ Passed |
Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title check |
✅ Passed |
The title 'Rename stdlib files to match Python module names' clearly and accurately describes the main change: renaming Rust stdlib source files with leading underscores to correspond to their Python module names. |
| Docstring Coverage |
✅ Passed |
Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. |
✏️ 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.
Add _ prefix to source files whose Python module names
start with _: ast→_ast, codecs→_codecs, collections→_collections,
ctypes→_ctypes, functools→_functools, imp→_imp, io→_io,
operator→_operator, signal→_signal, sre→_sre, stat→_stat,
string→_string, symtable→_symtable, sysconfig→_sysconfig,
sysconfigdata→_sysconfigdata, thread→_thread, typing→_typing,
warnings→_warnings, weakref→_weakref.
Update mod.rs and all cross-crate references accordingly.
Uh oh!
There was an error while loading. Please reload this page.
Reviewers
moreal
moreal approved these changes
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.
|