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
| 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.
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