Add some clippy lints by ShaharNaveh · Pull Request #7755 · RustPython/RustPython
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 resumeto resume automatic reviews.@coderabbitai reviewto trigger a single review.
Use the checkboxes below for quick actions:
-
▶️ Resume reviews - 🔍 Trigger review
📝 Walkthrough
Walkthrough
Adds nine Clippy lints to workspace config and performs widespread micro-refactors: consolidates match patterns, replaces eager fallbacks with lazy closures, and eliminates redundant clones across many crates without changing public APIs or core control flow.
Changes
| Cohort / File(s) | Summary |
|---|---|
Clippy Configuration Cargo.toml |
Added nine new Clippy lint rules under [workspace.lints.clippy] at warning level. |
Codegen crates/codegen/src/compile.rs, crates/codegen/src/ir.rs, crates/codegen/src/symboltable.rs |
Grouped/combined match patterns and moved ownership instead of cloning in several places; minor test/assert pattern formatting. |
Common: formatting & strings crates/common/src/format.rs, crates/common/src/str.rs |
Consolidated match arms and changed eager defaults (unwrap_or) to lazy closures (unwrap_or_else) in formatting and zfill logic. |
Derive macros crates/derive-impl/src/pyclass.rs, crates/derive-impl/src/pystructseq.rs |
Combined match arms and consumed structs in-place (avoiding clones) for macro generation. |
Stdlib (various modules) crates/stdlib/src/_asyncio.rs, .../contextvars.rs, .../csv.rs, .../mmap.rs, .../socket.rs, .../ssl.rs, .../ssl/cert.rs, .../ssl/compat.rs, .../unicodedata.rs |
Removed redundant clones, consolidated patterns, made default constructions lazy, and tightened some OS/path error handling. |
VM builtins & core crates/vm/src/builtins/..., crates/vm/src/codecs.rs, crates/vm/src/exception_group.rs, crates/vm/src/exceptions.rs |
Moved values instead of cloning, used lazy default/error construction, and simplified pattern matches; added a Clippy expect in one site. |
VM internals & utilities crates/vm/src/frame.rs, crates/vm/src/buffer.rs, crates/vm/src/getpath.rs, crates/vm/src/import.rs, crates/vm/src/ospath.rs |
Optimized ownership (move vs clone), accepted additional endianness marker, and made several fallbacks lazy. |
_ctypes family crates/vm/src/stdlib/_ctypes.rs, .../array.rs, .../base.rs, .../function.rs, .../pointer.rs, .../simple.rs, .../structure.rs, .../union.rs |
Consolidated PEP‑3118/type-code patterns, removed redundant clones, made error/default creation lazy, simplified read/write helpers, and adjusted ownership. |
Misc stdlib & VM modules crates/vm/src/stdlib/_abc.rs, .../_ast/python.rs, .../_io.rs, .../_sre.rs, .../_sysconfigdata.rs, .../_thread.rs, crates/vm/src/stdlib/builtins.rs, .../itertools.rs, .../sys.rs, .../time.rs, .../types/structseq.rs, crates/vm/src/vm/mod.rs, crates/vm/src/warn.rs |
Eliminated extra clones, switched eager constructions to lazy closures, and streamlined internal initializer/lookup paths without changing public APIs. |
Sequence Diagram(s)
(Skipped — changes are refactors/ownership and do not introduce new multi-component control flows.)
Estimated code review effort
🎯 3 (Moderate) | ⏱️ ~25 minutes
Possibly related PRs
- Apply some clippy lints #6045: Overlapping, related edits touching codegen and common formatting helpers (style/ownership refactors).
Suggested reviewers
- youknowone
- coolreader18
Poem
🐇
I munched the clones, I paired the match,
Closed lazy doors with a tiny latch,
I moved the bits where they should be,
Tidied patterns for all to see,
The repo hops on — light-footed and spry.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
| Check name | Status | Explanation |
|---|---|---|
| Description Check | ✅ Passed | Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title check | ✅ Passed | The title 'Add some clippy lints' accurately describes the primary change in the changeset, which is adding nine new Clippy lint configuration rules to Cargo.toml. |
| Docstring Coverage | ✅ Passed | Docstring coverage is 91.96% which is sufficient. The required threshold is 80.00%. |
| Linked Issues check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
✏️ Tip: You can configure your own custom pre-merge checks in the settings.
✨ Finishing Touches
🧪 Generate unit tests (beta)
- Create PR with unit tests
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.
Comment @coderabbitai help to get the list of available commands and usage tips.