Skip to content

Conversation

danparizher
Copy link
Contributor

Summary

Fixes #19596

Copy link
Contributor

github-actions bot commented Jul 31, 2025

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

@ntBre ntBre self-requested a review July 31, 2025 12:56
@ntBre ntBre added bug Something isn't working fixes Related to suggested fixes for violations labels Jul 31, 2025
@ntBre ntBre changed the title [flake8_errmsg] Exclude typing.cast from EM101 [flake8-errmsg] Exclude typing.cast from EM101 Jul 31, 2025
Copy link
Contributor

@ntBre ntBre left a comment

Choose a reason for hiding this comment

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

Thanks! Just one small simplification suggestion and an idea for a follow-up, if you're interested.

Comment on lines 185 to 189
if let Expr::Call(ast::ExprCall { func, .. }) = exc {
if checker.semantic().match_typing_expr(func, "cast") {
return;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: this looks identical to the if-let below. Can we just add func to the destructuring there and return from inside the if?

It looks like this whole function would be nicer as a sequence of early returns:

let Expr::Call ... else return;
if checker.semantic().match_typing_expr(func, cast) return;
let Some(first) = args.first() else return;

but let's save that for a quick follow-up.

@danparizher danparizher requested a review from ntBre July 31, 2025 22:51
@ntBre ntBre merged commit dce25da into astral-sh:main Aug 1, 2025
35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixes Related to suggested fixes for violations
Projects
None yet
Development

Successfully merging this pull request may close these issues.

EM101 false positive
2 participants