-
-
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.
Use qualified name when checking for overgeneral exceptions (#7497)
* Update tests * Use qualified name when checking for overgeneral exceptions * WIP: Add deprecation warning * Add changelog fragment * Use qualified name in test case * spell check fix * Update changelog fragment with suggested fixes Co-authored-by: Daniël van Noord <13665637+DanielNoord@users.noreply.github.com> * Move OVERGENERAL_EXCEPTIONS directly to the default value in dict * Mark as TODO for pylint 3.0 * Properly warn on each occurrence of name without dots * Update the warning per the review * Rephrase the warning to mention pylint 3.0 * Remove unnecessary nesting of the if condition * Quote the exception name in deprecation warning * Use config value for overgeneral exceptions in broad-exception-raised * Infer qualified name of the exception in broad-exception-raised * e.g. -> maybe? Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com> * Suppress missing class docstrings * Add few more tests for broad-exception-raised Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com> * Fix unexpected missing-raise-from * Revert "Fix unexpected missing-raise-from" This reverts commit d796e72. * Revert "Add few more tests for broad-exception-raised" This reverts commit e5a193e. * Change confidence of broad-exception-raised from HIGH to INFERENCE * Only trigger broad-exception-raised for raise with new exc instance * Update overgeneral-exceptions definition in example pylintrc file * Update pylint/checkers/exceptions.py Co-authored-by: Daniël van Noord <13665637+DanielNoord@users.noreply.github.com> Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
- Loading branch information
1 parent
88701fa
commit ac65bdc
Showing
13 changed files
with
134 additions
and
28 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Allow specifying non-builtin exceptions in the ``overgeneral-exception`` option | ||
using an exception's qualified name. | ||
|
||
Closes #7495 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[EXCEPTIONS] | ||
overgeneral-exceptions=builtins.BaseException, | ||
builtins.Exception, | ||
functional.b.broad_exception_caught.CustomBroadException |
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,2 +1,3 @@ | ||
broad-exception-caught:6:7:6:16::Catching too general exception Exception:INFERENCE | ||
broad-exception-caught:12:7:12:20::Catching too general exception BaseException:INFERENCE | ||
broad-exception-caught:14:7:14:16::Catching too general exception Exception:INFERENCE | ||
broad-exception-caught:20:7:20:20::Catching too general exception BaseException:INFERENCE | ||
broad-exception-caught:32:7:32:27::Catching too general exception CustomBroadException:INFERENCE |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[EXCEPTIONS] | ||
overgeneral-exceptions=builtins.BaseException, | ||
builtins.Exception, | ||
functional.b.broad_exception_raised.CustomBroadException |
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,5 +1,8 @@ | ||
broad-exception-raised:5:4:5:41:exploding_apple:"Raising too general exception: Exception":HIGH | ||
broad-exception-raised:10:8:10:34:raise_and_catch:"Raising too general exception: Exception":HIGH | ||
broad-exception-caught:11:11:11:20:raise_and_catch:Catching too general exception Exception:INFERENCE | ||
broad-exception-raised:14:0:14:17::"Raising too general exception: Exception":HIGH | ||
broad-exception-raised:15:0:15:21::"Raising too general exception: BaseException":HIGH | ||
broad-exception-raised:15:4:15:41:exploding_apple:"Raising too general exception: Exception":INFERENCE | ||
broad-exception-raised:20:8:20:34:raise_and_catch:"Raising too general exception: Exception":INFERENCE | ||
broad-exception-caught:21:11:21:20:raise_and_catch:Catching too general exception Exception:INFERENCE | ||
broad-exception-raised:38:8:38:35:raise_catch_raise:"Raising too general exception: Exception":INFERENCE | ||
broad-exception-raised:46:8:46:40:raise_catch_raise_using_alias:"Raising too general exception: Exception":INFERENCE | ||
broad-exception-raised:48:0:48:17::"Raising too general exception: Exception":INFERENCE | ||
broad-exception-raised:49:0:49:21::"Raising too general exception: BaseException":INFERENCE | ||
broad-exception-raised:50:0:50:28::"Raising too general exception: CustomBroadException":INFERENCE |