-
Notifications
You must be signed in to change notification settings - Fork 109
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
add except* support to B012&B025 #500
Conversation
I think the simple copy paste for tests is usually worth it over more complext helper functions etc. - But I see here how our tests simplicity create annoying amounts of fun ... I don't think I want a except_star.py ... As for updated messages, it's just the same error inside a try/except right? If so, I don't think we need to change the messages. If I've missed context just share. But PR seems good to me. |
I might give #419 a shot, in which case keeping to the current structure also makes it simpler. The downside of copy-paste would be having to maintain multiple copies, but that shouldn't be much of an issue here since these test files shouldn't see much/any changes in the future (and extremely unlikely that behavior would differ between
Yeah it's literally just saying |
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.
All sounds good to me. I'll leave the complexity choice to you.
One thing I don't see how it works, are our checks for except*
now somehow recursive to now include all subclasses for the specified exception(s)? If so how, is it inbuilt to the methods used somehow?
I'll just keep it as is then. Matches ruff as well.
I don't follow, what is this referring to? |
What makes our checks know about |
|
I think I'm mis-understanding the use of |
This PR creates a
visit_TryStar
that mostly just callsvisit_Try
, enabling B012 & B025 to work withtry/except*
Because
ExceptHandler
is also used forTryStar
, we already have support for free for B014, B029, B030, B036 and B904.I opted to add tests for them anyway, but it did end up with a somewhat silly amount of added tests - most of which are just pure copy-paste's of their original test files. Another option is writing a single
except_star.py
file that tests all of them, or writing a transformer test that goes through the original files, does a search+replace forexcept
->except*
, and then tests them on the fly. Though the latter option would also involve some rejigging to get the expected errors shared from the originaltest_bxxx
functions.Another case for #419
B001 is the only except-related rule I found that's not revelant, since
except*:
is a syntax error.EDIT: error message updates added in adca610
I have not updated error messages. For B012 (unclear if necessary) and B025 it'd be fairly straightforward, could makevisit_TryStar
pass a parameter tocheck_for_b012
/check_for_b025
. For the others it'd have to involve a propertyBugBearVisitor.in_trystar
... I guess I should just do that, even if somewhat tedious.