-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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.
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
Improve error messages for except* (B025, B029, B030, B904) #14791 #14815
Improve error messages for except* (B025, B029, B030, B904) #14791 #14815
Conversation
crates/ruff_linter/src/rules/flake8_bugbear/rules/duplicate_exceptions.rs
Outdated
Show resolved
Hide resolved
If you're able, can you run |
Yes, sure thing. I've ran the tests locally before committing. However, I didn't know how to accept my test modifications. Thank you 👌 I will be doing that with in the next commit. |
BTW @charliermarsh Since I am going to fix a couple more rules also. (B025, B029, B030, B904) Does it make sense to do the following change in the statement parser: ExceptHandler::ExceptHandler(ast::ExceptHandlerExceptHandler {
type_,
name,
body: except_body,
range: self.node_range(start),
in_trystar: block_kind.is_star(), <---- `try` block kind
}), so that |
@smokyabdulrahman -- I'd prefer not to change the parser / AST, if possible. |
|
b075f68
to
e57470a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
let is_star = checker | ||
.semantic() | ||
.current_statement() | ||
.as_try_stmt() | ||
.is_some_and(|try_stmt| try_stmt.is_star); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just for learning purposes. @MichaReiser
Why was this moved inside the diagnostic-branch
?
I thought calculating it outside the loop once would be better.
Improves error message for except* (Rules: B025, B029, B030, B904)
Example python snippet:
Error messages
Before:
After:
Closes #14791