-
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.
Make
TRY201
always autofixable (#6008)
## Summary Make `TRY201` always autofiable. ## Test Plan 1. `cargo test` 2. `cargo insta review` ref: #4333 (comment)
- Loading branch information
1 parent
3b56f6d
commit 700c816
Showing
2 changed files
with
55 additions
and
19 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
36 changes: 33 additions & 3 deletions
36
...rules/tryceratops/snapshots/ruff__rules__tryceratops__tests__verbose-raise_TRY201.py.snap
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,57 @@ | ||
--- | ||
source: crates/ruff/src/rules/tryceratops/mod.rs | ||
--- | ||
TRY201.py:20:15: TRY201 Use `raise` without specifying exception name | ||
TRY201.py:20:15: TRY201 [*] Use `raise` without specifying exception name | ||
| | ||
18 | except MyException as e: | ||
19 | logger.exception("process failed") | ||
20 | raise e | ||
| ^ TRY201 | ||
| | ||
= help: Remove exception name | ||
|
||
TRY201.py:63:19: TRY201 Use `raise` without specifying exception name | ||
ℹ Suggested fix | ||
17 17 | process() | ||
18 18 | except MyException as e: | ||
19 19 | logger.exception("process failed") | ||
20 |- raise e | ||
20 |+ raise | ||
21 21 | | ||
22 22 | | ||
23 23 | def good(): | ||
|
||
TRY201.py:63:19: TRY201 [*] Use `raise` without specifying exception name | ||
| | ||
61 | logger.exception("process failed") | ||
62 | if True: | ||
63 | raise e | ||
| ^ TRY201 | ||
| | ||
= help: Remove exception name | ||
|
||
ℹ Suggested fix | ||
60 60 | except MyException as e: | ||
61 61 | logger.exception("process failed") | ||
62 62 | if True: | ||
63 |- raise e | ||
63 |+ raise | ||
64 64 | | ||
65 65 | | ||
66 66 | def bad_that_needs_recursion_2(): | ||
|
||
TRY201.py:74:23: TRY201 Use `raise` without specifying exception name | ||
TRY201.py:74:23: TRY201 [*] Use `raise` without specifying exception name | ||
| | ||
73 | def foo(): | ||
74 | raise e | ||
| ^ TRY201 | ||
| | ||
= help: Remove exception name | ||
|
||
ℹ Suggested fix | ||
71 71 | if True: | ||
72 72 | | ||
73 73 | def foo(): | ||
74 |- raise e | ||
74 |+ raise | ||
|
||
|