[flake8-errmsg] Exclude typing.cast from EM101#19656
Merged
ntBre merged 2 commits intoastral-sh:mainfrom Aug 1, 2025
Merged
Conversation
Contributor
|
flake8_errmsg] Exclude typing.cast from EM101flake8-errmsg] Exclude typing.cast from EM101
ntBre
approved these changes
Jul 31, 2025
Contributor
ntBre
left a comment
There was a problem hiding this comment.
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; | ||
| } | ||
| } |
Contributor
There was a problem hiding this comment.
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.
ntBre
approved these changes
Aug 1, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Fixes #19596