Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added try-except-raise message example #6540

Merged
merged 4 commits into from
May 9, 2022

Conversation

matusvalo
Copy link
Collaborator

Type of Changes

Type
πŸ› Bug fix
✨ New feature
πŸ”¨ Refactoring
βœ“ πŸ“œ Docs

Description

Related #5953

@jacobtylerwalls
Copy link
Member

jacobtylerwalls commented May 7, 2022

Thanks. Is details.rst a good place to summarize the discussion from #5884 (comment) involving filtering exceptions? [EDIT: I suppose it might be a good idea to add an example with filtering of exceptions.]

Copy link
Member

@Pierre-Sassoulas Pierre-Sassoulas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that we should add a detail.rst, to be clear that there's a legitimate use case for re raising immediately but that this check is smart enough to not have a false positive for it.

I.e. with the following inheritance tree:

      +-- ArithmeticError
      |    +-- FloatingPointError
      |    +-- OverflowError
      |    +-- ZeroDivisionError
try:
    some_calculation(...)
except ZeroDivisionError as e:
    raise
except ArithmeticError:
   pass

will not get a pylint warning because ZeroDivisionError inherit from ArithmeticError.

doc/data/messages/t/try-except-raise/bad.py Outdated Show resolved Hide resolved
doc/data/messages/t/try-except-raise/good.py Outdated Show resolved Hide resolved
Co-authored-by: Pierre Sassoulas <[email protected]>
@matusvalo
Copy link
Collaborator Author

Added details.rst. Please review if now it is OK.

Copy link
Member

@Pierre-Sassoulas Pierre-Sassoulas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

πŸ‘

@Pierre-Sassoulas Pierre-Sassoulas merged commit cec1c6a into pylint-dev:main May 9, 2022
@matusvalo matusvalo deleted the try-except-raise branch May 9, 2022 13:17
@Pierre-Sassoulas Pierre-Sassoulas removed this from the 2.14.0 milestone May 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants