too-many-try-statements should exclude pass
statements if required by Python
#9418
Labels
Enhancement ✨
Improvement to a component
Needs PR
This issue is accepted, sufficiently specified and now needs an implementation
Current problem
I have code like this
The too-many-try-statements optional checker flags this as 2 statements, which is technically true, but the second statement,
pass
, is there only because the with block will cause SyntaxError without it.Desired solution
It probably isn't a good idea to completely ignore any/all
pass
statements, though that would be the easiest way to solve this, but the check should at least ignorepass
when it's required to by Python.A more judicious approach would be "ignore the second statement if all of these are true:
if ...:
,with ...:
,while ...:
, or the like.Or something along those lines
Additional context
No response
The text was updated successfully, but these errors were encountered: