Skip to content

Fix clippy warning#8249

Merged
youknowone merged 3 commits into
RustPython:mainfrom
bschoenmaeckers:fix-clippy
Jul 12, 2026
Merged

Fix clippy warning#8249
youknowone merged 3 commits into
RustPython:mainfrom
bschoenmaeckers:fix-clippy

Conversation

@bschoenmaeckers

@bschoenmaeckers bschoenmaeckers commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • Refactor
    • Simplified internal matching/argument-handling logic and minor control-flow expressions without changing behavior.
  • Bug Fixes
    • Improved formatting for debug/repr/qualname and error messages (including wider hex for UnicodeDecodeError, and cleaner formatting arguments for various builtins/IO/type messages).
  • Chores
    • Added/adjusted targeted Clippy lint suppressions for known false positives across runtime and stdlib code.

@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

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: 6af43a95-4f07-4a61-9c03-a1eabeca40d9

📥 Commits

Reviewing files that changed from the base of the PR and between 3a6a3ac and d3f79d5.

📒 Files selected for processing (4)
  • crates/host_env/src/fileutils.rs
  • crates/host_env/src/posix.rs
  • crates/vm/src/stdlib/_io.rs
  • crates/vm/src/stdlib/_signal.rs
🚧 Files skipped from review as they are similar to previous changes (3)
  • crates/host_env/src/fileutils.rs
  • crates/host_env/src/posix.rs
  • crates/vm/src/stdlib/_io.rs

📝 Walkthrough

Walkthrough

This PR simplifies Rust AST pattern matching, option/error control flow, formatting arguments, and Clippy annotations across codegen, VM, standard-library, host-environment, derive, and entry-point code without changing public declarations.

Changes

Rust cleanup

Layer / File(s) Summary
AST pattern simplification
crates/codegen/src/compile.rs, crates/codegen/src/symboltable.rs, crates/vm/src/stdlib/_ast/argument.rs
Unused AST fields are omitted from destructuring while scanning, validation, and argument splitting remain unchanged.
Control-flow simplification
crates/codegen/src/compile.rs, crates/vm/src/builtins/type.rs, crates/vm/src/frame.rs
Symbol lookup, module filtering, and mapping-match error propagation use concise equivalent control flow.
Formatting argument cleanup
crates/derive-impl/src/util.rs, crates/vm/src/**, src/lib.rs
Formatting and debug calls remove redundant explicit borrows while preserving messages and output.
Lint and literal cleanup
crates/host_env/src/*, crates/stdlib/src/*, crates/vm/src/stdlib/_io.rs, crates/vm/src/exceptions.rs
Clippy false positives are annotated, and selected byte, string, and hexadecimal formatting expressions are simplified.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested reviewers: ShaharNaveh, coolreader18

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 56.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: addressing a Clippy warning across the codebase.
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.
✨ 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.

❤️ Share

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

@bschoenmaeckers

Copy link
Copy Markdown
Contributor Author

The following error might be a bug in the latest stable rust. As it requires a unstable feature.

error: used import from `std` instead of `core`
   --> crates/host_env/src/fileutils.rs:468:13
    |
468 |             std::io::ErrorKind::InvalidInput,
    |             ^^^ help: consider importing the item from `core`: `core`

@fanninpm

Copy link
Copy Markdown
Contributor

The following error might be a bug in the latest stable rust. As it requires a unstable feature.

error: used import from `std` instead of `core`
   --> crates/host_env/src/fileutils.rs:468:13
    |
468 |             std::io::ErrorKind::InvalidInput,
    |             ^^^ help: consider importing the item from `core`: `core`

I was going to suggest reporting it to https://github.com/rust-lang/rust-clippy/issues, but this might be a duplicate of rust-lang/rust-clippy#15836.

@ShaharNaveh ShaharNaveh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ty:)

@ShaharNaveh

Copy link
Copy Markdown
Contributor

Forgot to say, I think it will be better for us to pin the channel at https://github.com/RustPython/RustPython/blob/main/rust-toolchain.toml to a specific version, like 1.96 for now. It's not ideal for us to have the CI break every couple of months every time a new stable version releases

- exceptions.rs: {b:#02x} -> {b:#04x} (unused_format_specs); output
  unchanged for decode-error bytes (always >= 0x80)
- binascii.rs: [b'\r', b'\n'] -> b"\r\n" (byte_str_slice)
- host_env, _io.rs, ssl.rs, pyexpat.rs: expect std_instead_of_core where
  the suggested core::io items (ErrorKind, Cursor) are unstable (core_io);
  use expect so the suppression is flagged for removal once core::io
  stabilizes. build_posix_spawn_attrs co-gates the expect with the cfg
  block so it is not left unfulfilled on platforms compiling it out.

Assisted-by: Claude
Comment thread crates/host_env/src/fileutils.rs Outdated
// _Py_fopen_obj in cpython (Python/fileutils.c:1757-1835)
// Open a file using std::fs::File and convert to FILE*
// Automatically handles path encoding and EINTR retries
#[expect(clippy::std_instead_of_core)] // false positive: core::io::ErrorKind is unstable (core_io)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you convert those to #[expect(..., reason="...")] please

@youknowone youknowone enabled auto-merge (squash) July 12, 2026 11:50

@ShaharNaveh ShaharNaveh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!

@youknowone youknowone merged commit 492e41c into RustPython:main Jul 12, 2026
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants