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

Feature request: lint for dropped exception after .add_note() #474

Closed
Zac-HD opened this issue Jun 20, 2024 · 1 comment · Fixed by #477
Closed

Feature request: lint for dropped exception after .add_note() #474

Zac-HD opened this issue Jun 20, 2024 · 1 comment · Fixed by #477

Comments

@Zac-HD
Copy link
Member

Zac-HD commented Jun 20, 2024

try:
    something()
except Exception as e:
    e.add_note("some helpful context")

This code is easy to write, but it has a nasty problem: you've just suppressed the exception! I think there should be a lint warning which triggers if you .add_note() an exception which is not either followed by a raise or raise e, or included in a function call or rhs of an assignment expression.

@cooperlees
Copy link
Collaborator

Sounds sane and I welcome the PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants