PyCQA / flake8-bugbear

A plugin for Flake8 finding likely bugs and design problems in your program. Contains warnings that don't belong in pyflakes and pycodestyle.
MIT License
1.05k stars 103 forks source link

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

Closed Zac-HD closed 1 week ago

Zac-HD commented 2 weeks ago
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 commented 2 weeks ago

Sounds sane and I welcome the PR.