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

Unlcear that BLE001 is suppressed when logging/raising error. #9571

Closed
ollz272 opened this issue Jan 18, 2024 · 0 comments · Fixed by #9580
Closed

Unlcear that BLE001 is suppressed when logging/raising error. #9571

ollz272 opened this issue Jan 18, 2024 · 0 comments · Fixed by #9580
Assignees
Labels
documentation Improvements or additions to documentation

Comments

@ollz272
Copy link

ollz272 commented Jan 18, 2024

The documentation isn't clear when BLE001 gets suppressed. Looking at the following code:

"""TEST."""
import logging

log = logging.getLogger(__name__)


def my_func() -> None:  # noqa: D103
    pass


try:
    my_func()
except Exception:
    log.exception("hello")

try:
    my_func()
except Exception:
    my_func()
    raise

try:
    my_func()
except Exception:
    my_func()

Only the last try statement gets picked up as BLE001. So im guessing the following rules apply:

  • If we log the exception in the except block, dont raise BLE001
  • If we raise the exception in the except block, dont raise BLE001

However, this isn't clear from the documentation - it just implies bare excepts will cause it. Can this be updated so we understand the rules better, please?

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

Successfully merging a pull request may close this issue.

2 participants