-
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.
[
tryceratops
] - add fix for error-instead-of-exception
(TRY400
)
- Loading branch information
1 parent
6183b8e
commit ac1c934
Showing
4 changed files
with
213 additions
and
4 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
160 changes: 160 additions & 0 deletions
160
...ceratops/snapshots/ruff_linter__rules__tryceratops__tests__preview__TRY400_TRY400.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 |
---|---|---|
@@ -0,0 +1,160 @@ | ||
--- | ||
source: crates/ruff_linter/src/rules/tryceratops/mod.rs | ||
--- | ||
TRY400.py:16:9: TRY400 [*] Use `logging.exception` instead of `logging.error` | ||
| | ||
14 | a = 1 | ||
15 | except Exception: | ||
16 | logging.error("Context message here") | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TRY400 | ||
17 | | ||
18 | if True: | ||
| | ||
= help: Replace with `exception` | ||
|
||
ℹ Safe fix | ||
13 13 | try: | ||
14 14 | a = 1 | ||
15 15 | except Exception: | ||
16 |- logging.error("Context message here") | ||
16 |+ logging.exception("Context message here") | ||
17 17 | | ||
18 18 | if True: | ||
19 19 | logging.error("Context message here") | ||
|
||
TRY400.py:19:13: TRY400 [*] Use `logging.exception` instead of `logging.error` | ||
| | ||
18 | if True: | ||
19 | logging.error("Context message here") | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TRY400 | ||
| | ||
= help: Replace with `exception` | ||
|
||
ℹ Safe fix | ||
16 16 | logging.error("Context message here") | ||
17 17 | | ||
18 18 | if True: | ||
19 |- logging.error("Context message here") | ||
19 |+ logging.exception("Context message here") | ||
20 20 | | ||
21 21 | | ||
22 22 | def bad(): | ||
|
||
TRY400.py:26:9: TRY400 [*] Use `logging.exception` instead of `logging.error` | ||
| | ||
24 | a = 1 | ||
25 | except Exception: | ||
26 | logger.error("Context message here") | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TRY400 | ||
27 | | ||
28 | if True: | ||
| | ||
= help: Replace with `exception` | ||
|
||
ℹ Safe fix | ||
23 23 | try: | ||
24 24 | a = 1 | ||
25 25 | except Exception: | ||
26 |- logger.error("Context message here") | ||
26 |+ logger.exception("Context message here") | ||
27 27 | | ||
28 28 | if True: | ||
29 29 | logger.error("Context message here") | ||
|
||
TRY400.py:29:13: TRY400 [*] Use `logging.exception` instead of `logging.error` | ||
| | ||
28 | if True: | ||
29 | logger.error("Context message here") | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TRY400 | ||
| | ||
= help: Replace with `exception` | ||
|
||
ℹ Safe fix | ||
26 26 | logger.error("Context message here") | ||
27 27 | | ||
28 28 | if True: | ||
29 |- logger.error("Context message here") | ||
29 |+ logger.exception("Context message here") | ||
30 30 | | ||
31 31 | | ||
32 32 | def bad(): | ||
|
||
TRY400.py:36:9: TRY400 [*] Use `logging.exception` instead of `logging.error` | ||
| | ||
34 | a = 1 | ||
35 | except Exception: | ||
36 | log.error("Context message here") | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TRY400 | ||
37 | | ||
38 | if True: | ||
| | ||
= help: Replace with `exception` | ||
|
||
ℹ Safe fix | ||
33 33 | try: | ||
34 34 | a = 1 | ||
35 35 | except Exception: | ||
36 |- log.error("Context message here") | ||
36 |+ log.exception("Context message here") | ||
37 37 | | ||
38 38 | if True: | ||
39 39 | log.error("Context message here") | ||
|
||
TRY400.py:39:13: TRY400 [*] Use `logging.exception` instead of `logging.error` | ||
| | ||
38 | if True: | ||
39 | log.error("Context message here") | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TRY400 | ||
| | ||
= help: Replace with `exception` | ||
|
||
ℹ Safe fix | ||
36 36 | log.error("Context message here") | ||
37 37 | | ||
38 38 | if True: | ||
39 |- log.error("Context message here") | ||
39 |+ log.exception("Context message here") | ||
40 40 | | ||
41 41 | | ||
42 42 | def bad(): | ||
|
||
TRY400.py:46:9: TRY400 [*] Use `logging.exception` instead of `logging.error` | ||
| | ||
44 | a = 1 | ||
45 | except Exception: | ||
46 | self.logger.error("Context message here") | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TRY400 | ||
47 | | ||
48 | if True: | ||
| | ||
= help: Replace with `exception` | ||
|
||
ℹ Safe fix | ||
43 43 | try: | ||
44 44 | a = 1 | ||
45 45 | except Exception: | ||
46 |- self.logger.error("Context message here") | ||
46 |+ self.logger.exception("Context message here") | ||
47 47 | | ||
48 48 | if True: | ||
49 49 | self.logger.error("Context message here") | ||
|
||
TRY400.py:49:13: TRY400 [*] Use `logging.exception` instead of `logging.error` | ||
| | ||
48 | if True: | ||
49 | self.logger.error("Context message here") | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TRY400 | ||
| | ||
= help: Replace with `exception` | ||
|
||
ℹ Safe fix | ||
46 46 | self.logger.error("Context message here") | ||
47 47 | | ||
48 48 | if True: | ||
49 |- self.logger.error("Context message here") | ||
49 |+ self.logger.exception("Context message here") | ||
50 50 | | ||
51 51 | | ||
52 52 | def good(): | ||
|
||
|