-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…14815) Improves error message for [except*](https://peps.python.org/pep-0654/) (Rules: B025, B029, B030, B904) Example python snippet: ```python 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 ``` Error messages Before: ``` $ 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. ``` After: ``` $ 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. ``` Closes #14791 --------- Co-authored-by: Micha Reiser <[email protected]>
- Loading branch information
1 parent
269e47b
commit 8540209
Showing
12 changed files
with
312 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.