◐ Shell
clean mode source ↗

Rename stdlib files to match Python module names by youknowone · Pull Request #7397 · RustPython/RustPython

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

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.