GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Enable some pedantic clippy lints by ShaharNaveh · Pull Request #7764 · RustPython/RustPython

Enable some pedantic clippy lints #7764

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Sign up for GitHub

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
youknowone merged 14 commits into RustPython:main from ShaharNaveh:clippy-lints-0
May 4, 2026

Uh oh!

There was an error while loading. Please reload this page.

Merged

Enable some pedantic clippy lints #7764

Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
14 commits
Select commit Hold shift + click to select a range
b54c1aa
Set `#[must_use]` where possible
ShaharNaveh May 2, 2026
f3587f6
redundant_else
ShaharNaveh May 2, 2026
7e08309
Fix doc
ShaharNaveh May 2, 2026
938790a
Add some clippy rules
ShaharNaveh May 2, 2026
d2f0c6f
Enfore `cloned_instead_of_copied`
ShaharNaveh May 2, 2026
840fc07
Remove dup import
ShaharNaveh May 2, 2026
37418c5
Fix more
ShaharNaveh May 2, 2026
6326047
fix wasm
ShaharNaveh May 2, 2026
55444fc
more
ShaharNaveh May 2, 2026
3dd0fb5
more
ShaharNaveh May 2, 2026
b017713
fix
ShaharNaveh May 2, 2026
d01b279
Merge remote-tracking branch 'upstream/main' into clippy-lints-0
ShaharNaveh May 2, 2026
d293a25
Fix more
ShaharNaveh May 2, 2026
8a56ff1
Fix typo
ShaharNaveh May 2, 2026
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view
Prev Previous commit
Next Next commit
redundant_else
  • Loading branch information

Uh oh!

There was an error while loading. Please reload this page.

@ShaharNaveh
ShaharNaveh committed May 2, 2026
commit f3587f66a3ed5f2044c406967cfdc39f398f44f8

There are no files selected for viewing

15 changes: 6 additions & 9 deletions 15 crates/codegen/src/compile.rs
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -6268,12 +6268,11 @@ impl Compiler {
return Err(self.error(CodegenErrorType::UnreachablePattern(
PatternUnreachableReason::NameCapture,
)));
} else {
// A wildcard makes remaining patterns unreachable.
return Err(self.error(CodegenErrorType::UnreachablePattern(
PatternUnreachableReason::Wildcard,
)));
}
// A wildcard makes remaining patterns unreachable.
return Err(self.error(CodegenErrorType::UnreachablePattern(
PatternUnreachableReason::Wildcard,
)));
}
// If irrefutable matches are allowed, store the name (if any).
return self.pattern_helper_store_name(p.name.as_ref(), pc);
Expand Down Expand Up @@ -10329,9 +10328,8 @@ impl Compiler {
if !found_loop {
if is_break {
return Err(self.error_ranged(CodegenErrorType::InvalidBreak, range));
} else {
return Err(self.error_ranged(CodegenErrorType::InvalidContinue, range));
}
return Err(self.error_ranged(CodegenErrorType::InvalidContinue, range));
}
return Ok(());
}
Expand Down Expand Up @@ -10370,9 +10368,8 @@ impl Compiler {
let Some(loop_idx) = loop_idx else {
if is_break {
return Err(self.error_ranged(CodegenErrorType::InvalidBreak, range));
} else {
return Err(self.error_ranged(CodegenErrorType::InvalidContinue, range));
}
return Err(self.error_ranged(CodegenErrorType::InvalidContinue, range));
};

let loop_block = code.fblock[loop_idx].fb_block;
Expand Down
12 changes: 5 additions & 7 deletions 12 crates/common/src/format.rs
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -1357,20 +1357,18 @@ impl FormatString {
} else if c == '{' {
if nested {
return Err(FormatParseError::InvalidFormatSpecifier);
} else {
nested = true;
left.push(c);
continue;
}
nested = true;
left.push(c);
continue;
} else if c == '}' {
if nested {
nested = false;
left.push(c);
continue;
} else {
end_bracket_pos = Some(idx);
break;
}
end_bracket_pos = Some(idx);
break;
} else {
left.push(c);
}
Expand Down
9 changes: 4 additions & 5 deletions 9 crates/common/src/lock/thread_mutex.rs
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,11 @@ impl<R: RawMutex, G: GetThreadId> RawThreadMutex<R, G> {
let id = self.get_thread_id.nonzero_thread_id().get();
if self.owner.load(Ordering::Relaxed) == id {
return None;
} else {
if !try_lock() {
return Some(false);
}
self.owner.store(id, Ordering::Relaxed);
}
if !try_lock() {
return Some(false);
}
self.owner.store(id, Ordering::Relaxed);
Some(true)
}

Expand Down
3 changes: 1 addition & 2 deletions 3 crates/derive-impl/src/compile_bytecode.rs
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,8 @@ impl CompilationSource {
let joined = path.parent().unwrap().join(real_path.trim());
if joined.exists() {
return compile_path(&joined);
} else {
return Err(e);
}
return Err(e);
}
Err(e)
});
Expand Down
3 changes: 1 addition & 2 deletions 3 crates/derive-impl/src/pyclass.rs
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -2014,9 +2014,8 @@ where
Err(wrong_name) => {
if ALL_ALLOWED_NAMES.contains(&attr_name.as_str()) {
bail_span!(attr, "#[pyclass] doesn't accept #[{}]", wrong_name)
} else {
continue;
}
continue;
}
};

Expand Down
3 changes: 1 addition & 2 deletions 3 crates/derive-impl/src/pymodule.rs
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -469,9 +469,8 @@ where
continue;
} else if closed {
bail_span!(attr, "Only one #[pyattr] annotated #[py*] item can exist")
} else {
bail_span!(attr, "#[pymodule] doesn't accept #[{}]", wrong_name)
}
bail_span!(attr, "#[pymodule] doesn't accept #[{}]", wrong_name)
}
};

Expand Down
15 changes: 6 additions & 9 deletions 15 crates/derive-impl/src/pystructseq.rs
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -451,9 +451,8 @@ impl PyStructSequenceMeta {
inner.meta_ident,
"#[pystruct_sequence({KEY}=value)] expects a string value"
)
} else {
Ok(None)
}
Ok(None)
}

pub fn module(&self) -> Result<Option<String>> {
Expand All @@ -475,9 +474,8 @@ impl PyStructSequenceMeta {
inner.meta_ident,
"#[pystruct_sequence({KEY}=value)] expects a string value"
)
} else {
Ok(None)
}
Ok(None)
}

fn data_type(&self) -> Result<Ident> {
Expand All @@ -499,12 +497,11 @@ impl PyStructSequenceMeta {
inner.meta_ident,
"#[pystruct_sequence({KEY}=value)] expects a string value"
)
} else {
bail_span!(
inner.meta_ident,
"#[pystruct_sequence] requires data parameter (e.g., data = \"DataStructName\")"
)
}
bail_span!(
inner.meta_ident,
"#[pystruct_sequence] requires data parameter (e.g., data = \"DataStructName\")"
)
}

pub fn no_attr(&self) -> Result<bool> {
Expand Down
13 changes: 5 additions & 8 deletions 13 crates/sre_engine/src/engine.rs
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,8 @@ impl State {
if flags.contains(SreInfo::PREFIX) {
if flags.contains(SreInfo::LITERAL) {
return search_info_literal::<true, S>(&mut req, self, ctx);
} else {
return search_info_literal::<false, S>(&mut req, self, ctx);
}
return search_info_literal::<false, S>(&mut req, self, ctx);
} else if flags.contains(SreInfo::CHARSET) {
return search_info_charset(&mut req, self, ctx);
}
Expand Down Expand Up @@ -435,10 +434,9 @@ fn _match<S: StrDrive>(req: &Request<'_, S>, state: &mut State, mut ctx: MatchCo
if max_count == MAXREPEAT || ctx.count as usize <= max_count {
state.cursor = ctx.cursor;
break 'context ctx.next_peek_from(1, req, Jump::MinRepeatOne2);
} else {
state.marks.pop_discard();
break 'result false;
}
state.marks.pop_discard();
break 'result false;
}
Jump::MinRepeatOne2 => {
if popped_result {
Expand Down Expand Up @@ -488,10 +486,9 @@ fn _match<S: StrDrive>(req: &Request<'_, S>, state: &mut State, mut ctx: MatchCo
ctx.count += 1;
ctx.jump = Jump::PossessiveRepeat1;
continue 'context;
} else {
state.cursor = ctx.cursor;
break 'result false;
}
state.cursor = ctx.cursor;
break 'result false;
}
Jump::PossessiveRepeat3 => {
let max_count = ctx.peek_code(req, 3) as usize;
Expand Down
5 changes: 2 additions & 3 deletions 5 crates/stdlib/src/compression.rs
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,9 @@ pub fn _decompress_chunks<D: Decompressor>(
} else if !chunk.is_empty() && consumed == 0 {
// we're gonna need a bigger buffer
continue;
} else {
// next chunk
continue 'outer;
}
// next chunk
continue 'outer;
}
Err(e) => {
d.maybe_set_dict(e)?;
Expand Down
5 changes: 2 additions & 3 deletions 5 crates/stdlib/src/ssl/cert.rs
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -812,10 +812,9 @@ impl<'a> CertLoader<'a> {
return Err(cert_error::der::not_enough_data(
"cadata does not contain a certificate",
));
} else {
// Loaded some certificates but failed on subsequent data (garbage)
return Err(cert_error::der::parse_failed(e));
}
// Loaded some certificates but failed on subsequent data (garbage)
return Err(cert_error::der::parse_failed(e));
}
}
}
Expand Down
42 changes: 20 additions & 22 deletions 42 crates/stdlib/src/ssl/compat.rs
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -2016,30 +2016,28 @@ fn ssl_read_tls_records(
if is_bio {
// In BIO mode, no data means WANT_READ
return Err(SslError::WantRead);
} else {
// In socket mode, empty recv() means TCP EOF (FIN received)
// Need to distinguish:
// 1. Clean shutdown: received TLS close_notify → return ZeroReturn (0 bytes)
// 2. Unexpected EOF: no close_notify → return Eof (SSLEOFError)
//
// SSL_ERROR_ZERO_RETURN vs SSL_ERROR_EOF logic
// CPython checks SSL_get_shutdown() & SSL_RECEIVED_SHUTDOWN
//
// Process any buffered TLS records (may contain close_notify)
match conn.process_new_packets() {
Ok(io_state) => {
if io_state.peer_has_closed() {
// Received close_notify - normal SSL closure (SSL_ERROR_ZERO_RETURN)
return Err(SslError::ZeroReturn);
} else {
// No close_notify - ragged EOF (SSL_ERROR_EOF → SSLEOFError)
// CPython raises SSLEOFError here, which SSLSocket.read() handles
// based on suppress_ragged_eofs setting
return Err(SslError::Eof);
}
}
// In socket mode, empty recv() means TCP EOF (FIN received)
// Need to distinguish:
// 1. Clean shutdown: received TLS close_notify → return ZeroReturn (0 bytes)
// 2. Unexpected EOF: no close_notify → return Eof (SSLEOFError)
//
// SSL_ERROR_ZERO_RETURN vs SSL_ERROR_EOF logic
// CPython checks SSL_get_shutdown() & SSL_RECEIVED_SHUTDOWN
//
// Process any buffered TLS records (may contain close_notify)
match conn.process_new_packets() {
Ok(io_state) => {
if io_state.peer_has_closed() {
// Received close_notify - normal SSL closure (SSL_ERROR_ZERO_RETURN)
return Err(SslError::ZeroReturn);
}
Err(e) => return Err(SslError::from_rustls(e)),
// No close_notify - ragged EOF (SSL_ERROR_EOF → SSLEOFError)
// CPython raises SSLEOFError here, which SSLSocket.read() handles
// based on suppress_ragged_eofs setting
return Err(SslError::Eof);
}
Err(e) => return Err(SslError::from_rustls(e)),
}
}

Expand Down
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.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.