pylint icon indicating copy to clipboard operation
pylint copied to clipboard

Use qualified name when checking for overgeneral exceptions

Open Jackenmen opened this issue 1 year ago • 4 comments

Type of Changes

Type
:bug: Bug fix
:hammer: Refactoring

Description

Allow specifying non-builtin exceptions in overgeneral-exception option using exception's qualified name.

Additionally, tries to deprecate specifying built-in exception names without dots. Small problem - I don't know how to tell pylint to warn about deprecation as warnings.warn(...) does not seem to be a valid way to do that.

Closes #7495

Jackenmen avatar Sep 19 '22 22:09 Jackenmen

Pull Request Test Coverage Report for Build 3119323835

  • 3 of 4 (75.0%) changed or added relevant lines in 1 file are covered.
  • 53 unchanged lines in 4 files lost coverage.
  • Overall coverage decreased (-0.02%) to 95.31%

Changes Missing Coverage Covered Lines Changed/Added Lines %
pylint/checkers/exceptions.py 3 4 75.0%
<!-- Total: 3 4
Files with Coverage Reduction New Missed Lines %
pylint/checkers/utils.py 4 95.22%
pylint/checkers/refactoring/recommendation_checker.py 7 96.41%
pylint/checkers/classes/class_checker.py 16 94.79%
pylint/checkers/typecheck.py 26 95.54%
<!-- Total: 53
Totals Coverage Status
Change from base Build 3083262479: -0.02%
Covered Lines: 17111
Relevant Lines: 17953

💛 - Coveralls

coveralls avatar Sep 19 '22 22:09 coveralls

🤖 According to the primer, this change has no effect on the checked open source code. 🤖🎉

This comment was generated for commit 1511de20f38165d907b86a9a57f8581c9a535928

github-actions[bot] avatar Sep 19 '22 22:09 github-actions[bot]

It keeps compatibility with the old way (names without dots are handled as they've been before and names with dots weren't supported in any way before) so I think it should be fine? The long-term goal is to remove the old way in 3.0 though.

The problem I've run into is that I don't really know how I should make pylint actually show the deprecation warning to the user (warnings.warn that's currently in here doesn't seem to work) which is why this PR is a draft.

Jackenmen avatar Sep 20 '22 04:09 Jackenmen

🤖 According to the primer, this change has no effect on the checked open source code. 🤖🎉

This comment was generated for commit c74398d9311c72c0b0b5f9b0f4f2da33355bb416

github-actions[bot] avatar Sep 20 '22 16:09 github-actions[bot]

Is this still a draft @jack1142 ?

Pierre-Sassoulas avatar Sep 24 '22 07:09 Pierre-Sassoulas

Is this still a draft @jack1142 ?

I was waiting for a resolution of the warning discussion before committing any changes. Should be ready for review now.

Jackenmen avatar Sep 24 '22 16:09 Jackenmen

🤖 According to the primer, this change has no effect on the checked open source code. 🤖🎉

This comment was generated for commit d4e982b1c3c9b0f25165811ca683a2766586d7b6

github-actions[bot] avatar Sep 24 '22 18:09 github-actions[bot]