GeezerVison is showing github.com — Clippy nursery lints by ShaharNaveh · Pull Request #7875 · RustPython/RustPython
Conversation
ShaharNaveh
commented
May 15, 2026
•
edited by coderabbitai
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
Summary by CodeRabbit
-
Chores
- Reorganized lint configuration and added additional Clippy warnings to improve code quality.
-
Refactor
- Large mechanical refactors to use generic/self-based patterns for more consistent subclassing and internal dispatch.
- Expanded equality trait derivations across many types for stronger comparisons.
- Small formatting and localized code cleanups while preserving behavior.
-
Behavior
- No user-facing behavior changes; runtime and public interfaces remain compatible.

Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
coderabbitai
Bot
commented
May 15, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Note
Reviews paused
It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.
Use the following commands to manage reviews:
@coderabbitai resume to resume automatic reviews.
@coderabbitai review to trigger a single review.
Use the checkboxes below for quick actions:
- ▶️ Resume reviews
- 🔍 Trigger review
📝 Walkthrough
Walkthrough
This PR replaces explicit concrete type names with Self across the codebase, adds Eq derives to many types, reorganizes workspace Clippy lint groups in Cargo.toml, and applies small expression refactors and constant-folding/formatting adjustments.
Changes
Clippy Lint Configuration and Equality Derivations
| Layer / File(s) |
Summary |
Clippy Lint Configuration Cargo.toml |
Reorganizes [workspace.lints.clippy] warn section into logical groups (restriction, nursery, pedantic) and adds several nursery-level lints including use_self, derive_partial_eq_without_eq, imprecise_flops, and others for gradual enforcement. |
Equality Trait Derivations crates/common/src/cformat.rs, crates/common/src/format.rs, crates/compiler-core/src/bytecode.rs, crates/vm/src/function/method.rs, crates/vm/src/stdlib/posix.rs |
Adds Eq trait to 20+ public enums and structs that already derive PartialEq, enabling stricter compile-time equality checks across formatting, bytecode, and metadata types. |
Systematic Self-Type Refactoring
| Layer / File(s) |
Summary |
Object Core and GC System crates/vm/src/object/core.rs |
Updates GC traversal, weakref handling, and type-safe pointer casting to use Self for generic type parameters; changes PyWeak::pointers type, weakref stripe lock keying, gc_get_referent_ptrs return type, and gc_clear_raw signature. |
VM Frame and Display Implementations crates/vm/src/frame.rs, crates/vm/src/object/ext.rs, crates/vm/src/datastack.rs, crates/vm/src/vm/context.rs |
Updates frame pointer return types, inline display trait bounds, linked-list pointer types, and context initialization to use Self consistently. |
Builtin Types Refactoring crates/vm/src/builtins/bytes.rs, crates/vm/src/builtins/code.rs, crates/vm/src/builtins/str.rs, crates/vm/src/builtins/tuple.rs, crates/vm/src/builtins/type.rs, and others |
Systematically replaces explicit type names with Self in constructors, downcasts, method implementations, and signature parameters across builtin types. |
Stdlib Modules Refactoring crates/stdlib/src/_asyncio.rs, crates/stdlib/src/ssl.rs, crates/stdlib/src/_io.rs, crates/stdlib/src/_functools.rs, and others |
Updates stdlib modules to use Self in constructors, downcasts, and method dispatches in finalizers, trait implementations, and FFI helpers for consistency. |
Ctypes Foreign Function Interface crates/vm/src/stdlib/_ctypes/array.rs, crates/vm/src/stdlib/_ctypes/base.rs, crates/vm/src/stdlib/_ctypes/function.rs, and others |
Refactors ctypes implementation to use Self for recursive method calls, struct construction, and type downcasting in field descriptors and type conversions. |
Compiler and Code Generation crates/codegen/src/compile.rs, crates/compiler-core/src/bytecode.rs, crates/vm/src/stdlib/_ast/constant.rs, and others |
Updates compiler layers and AST handling to use Self in pattern matching, struct construction, enum variants, and recursive type references. |
Expression Refactoring and Logic Enhancements
| Layer / File(s) |
Summary |
Statement to Expression Refactoring crates/stdlib/src/statistics.rs, crates/vm/src/vm/vm_object.rs, crates/vm/src/vm/vm_ops.rs |
Converts mutable variable assignments with conditional blocks into direct conditional expressions while preserving behavior. |
Complex Arithmetic and Slot Function Expansion crates/codegen/src/ir.rs, crates/vm/src/builtins/descriptor.rs, crates/vm/src/builtins/union.rs, and others |
Expands SlotFunc::call to explicitly handle descriptor, sequence, mapping, and number slot variants; preserves complex number signed-zero behavior; simplifies union getitem logic. |
Estimated code review effort
🎯 3 (Moderate) | ⏱️ ~25 minutes
Possibly related PRs
Suggested reviewers
- youknowone
- coolreader18
- fanninpm
"🐰 I hopped through code and changed each name,
Self now stands where types were once the same.
Eq joins PartialEq, lints are neatly lined,
A tidy burrow of types — happy, refined! 🥕"
✨ Finishing Touches
🧪 Generate unit tests (beta)
- Create PR with unit tests
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@crates/wasm/src/browser_module.rs`:
- Around line 26-31: The match arm for "array_buffer" double-wraps the result by
returning Ok(Self::ArrayBuffer) inside an outer Ok(match ...), causing an
Ok(Ok(...)); change the "array_buffer" arm to return Self::ArrayBuffer (i.e.,
remove the inner Ok) so all match arms produce the same variant type and the
outer Ok(...) yields Ok(Self::ArrayBuffer); update the match in the function
that parses the response format (the match on s returning Self::Json,
Self::Text, Self::ArrayBuffer and the Err from vm.new_type_error) to keep
consistent return types.
- Around line 181-189: The free-standing function document is using Self (only
valid inside impl blocks); change its signature and references to use the
concrete type name Document instead of Self: return PyRef<Document>, construct
Document { doc: ... } instead of Self { ... }, and call
Document::make_static_type() (or the appropriate associated function) for the
third argument to PyRef::new_ref so the function compiles at module scope.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
Run ID: b946ed2e-8ef9-4957-b4a7-ff4fdd64395e
📥 Commits
Reviewing files that changed from the base of the PR and between 906b799 and 660b9a4.
📒 Files selected for processing (6)
crates/jit/src/instructions.rs
crates/stdlib/src/_sqlite3.rs
crates/stdlib/src/grp.rs
crates/wasm/src/browser_module.rs
crates/wasm/src/js_module.rs
crates/wasm/src/vm_class.rs
✅ Files skipped from review due to trivial changes (2)
- crates/wasm/src/vm_class.rs
- crates/stdlib/src/grp.rs
🚧 Files skipped from review as they are similar to previous changes (1)
- crates/jit/src/instructions.rs
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
This was referenced Jun 7, 2026
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.
|