-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
diagnosticsRelated to reporting of diagnostics.Related to reporting of diagnostics.good first issueGood for newcomersGood for newcomershelp wantedContributions especially welcomeContributions especially welcome
Description
I did a pass on all flake8-bugbear rules upstream to check for except* handling (PyCQA/flake8-bugbear#500), and then also checked ruff.. which already handles all of them 🥳 But a bunch of them assume except in their message, which could perhaps be confusing to users - but tbh it's mostly a nitpick.
I have not checked any rules other than flake8-bugbear, so I suggest you do a pass checking for any other rules that might be referring to except.
try:
a = 1
except* ValueError:
a = 2
except* ValueError:
a = 2
try:
pass
except* ():
pass
try:
pass
except* 1: # error
pass
try:
raise ValueError
except* ValueError:
raise UserWarning$ ruff check --select=B foo.py
foo.py:6:9: B025 try-except block with duplicate exception `ValueError`
foo.py:11:1: B029 Using `except ():` with an empty tuple does not catch anything; add exceptions to handle
foo.py:16:9: B030 `except` handlers should only be exception classes or tuples of exception classes
foo.py:22:5: B904 Within an `except` clause, raise exceptions with `raise ... from err` or `raise ... from None` to distinguish them from errors in exception handling
Found 4 errors.
expected output
$ ruff check --select=B foo.py
foo.py:6:9: B025 try-except* block with duplicate exception `ValueError`
foo.py:11:1: B029 Using `except* ():` with an empty tuple does not catch anything; add exceptions to handle
foo.py:16:9: B030 `except*` handlers should only be exception classes or tuples of exception classes
foo.py:22:5: B904 Within an `except*` clause, raise exceptions with `raise ... from err` or `raise ... from None` to distinguish them from errors in exception handling
Found 4 errors.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
diagnosticsRelated to reporting of diagnostics.Related to reporting of diagnostics.good first issueGood for newcomersGood for newcomershelp wantedContributions especially welcomeContributions especially welcome