Skip to content

More clippy rules#8123

Merged
youknowone merged 6 commits into
RustPython:mainfrom
ShaharNaveh:clippy-rules-3
Jun 17, 2026
Merged

More clippy rules#8123
youknowone merged 6 commits into
RustPython:mainfrom
ShaharNaveh:clippy-rules-3

Conversation

@ShaharNaveh

@ShaharNaveh ShaharNaveh commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Summary

Summary by CodeRabbit

  • Refactor
    • Simplified boolean-to-integer conversions and conditional return logic across several components.
    • Streamlined a range-counting fast path to use direct boolean-to-usize conversion.
    • Adjusted handling for localhost IPv4 SNI to use the standard localhost constant (no behavioral change).
  • Chores
    • Updated the static analysis lint set in the pedantic configuration.
  • Documentation
    • Improved formatting of related documentation references for clarity.

@coderabbitai

coderabbitai Bot commented Jun 16, 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: b4e6b253-b5ea-48b4-8d30-514cbc1c216b

📥 Commits

Reviewing files that changed from the base of the PR and between 5a72251 and a51feed.

📒 Files selected for processing (1)
  • crates/host_env/src/overlapped.rs
✅ Files skipped from review due to trivial changes (1)
  • crates/host_env/src/overlapped.rs

📝 Walkthrough

Walkthrough

Extends the workspace Clippy pedantic lint configuration in Cargo.toml with eleven new warn-level entries and applies the resulting lint fixes across six crates: replacing if/else { 1 }/{ 0 } patterns with From<bool> conversions, substituting Ipv4Addr::LOCALHOST for the literal constructor, refactoring a comment-detection pattern, and updating doc comment formatting.

Changes

Clippy Lint Config and Fixes

Layer / File(s) Summary
Workspace Clippy lint configuration
Cargo.toml
Adds bool_to_int_with_if, doc_link_with_quotes, ip_constant, large_futures, non_std_lazy_statics, range_minus_one, range_plus_one, single_char_pattern, unchecked_time_subtraction, unnecessary_box_returns, and unnecessary_join as warn-level pedantic lints, with reordering of the surrounding entries.
bool_to_int_with_if fixes
crates/codegen/src/compile.rs, crates/host_env/src/ctypes.rs, crates/host_env/src/overlapped.rs, crates/vm/src/builtins/range.rs, crates/vm/src/stdlib/_ctypes/base.rs
Replaces if condition { 1 } else { 0 } patterns with u32::from(...), usize::from(...), u8::from(...), or i32::from(...) conversions in num_annotations, case_count, boolean ctypes encode/decode, PyRange::count, PyCData::_b_needsfree_, and PostQueuedCompletionStatus parameter passing.
ip_constant, doc_link_with_quotes, and _ast fixes
crates/stdlib/src/ssl.rs, crates/vm/src/stdlib/_ast.rs, crates/vm/src/warn.rs
Replaces Ipv4Addr::new(127, 0, 0, 1) with Ipv4Addr::LOCALHOST, refactors # comment-position detection in type_ignores_from_source to if let Some form, and updates three doc comments to use inline code backticks for sys.modules['warnings'].* references.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • youknowone
  • coolreader18

Poem

🐇 Hop hop, no if to fuss,
bool::from is cleaner for us!
LOCALHOST shines bright and clear,
New lints keep the codebase dear.
✨ The rabbit says: less noise, more cheer!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'More clippy rules' is vague and does not accurately reflect the primary changes, which involve applying specific Clippy lint rules across multiple files and updating Cargo.toml configuration. Consider a more descriptive title such as 'Apply bool_to_int_with_if and other Clippy lints' or 'Refactor code to match Clippy pedantic lints configuration' to clearly communicate the main objective.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% 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.

❤️ Share

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

@youknowone youknowone merged commit 93fbe4f into RustPython:main Jun 17, 2026
26 checks passed
@coderabbitai coderabbitai Bot mentioned this pull request Jun 17, 2026
2 tasks
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.

2 participants