B042 has naive definition of exception
Maintainers usually reply within 2 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 42/100
Research direction
Start in bugbear.py at the linked lines 1798-1802 and reproduce the FailOnException example from the issue. B042 should distinguish actual exception classes from classes whose names merely contain exception-related wording, while continuing to identify real exceptions.
Written by the indexing model from the issue text.
Description
B042 (introduced in #421 / #512) has a naive way of determining whether a class is an exception:
https://github.com/PyCQA/flake8-bugbear/blob/915edea6f1c7ca98fbc15f893917d1da46ae79c6/bugbear.py#L1798-L1802
It is based solely on the name of the class, which means it returns True even if the class is not an exception.
For example, if I have a context manager class called FailOnException, it will trigger, even though that class is not an exception at all:
from typing import (ContextManager, TypeVar)
T = TypeVar("T")
class FailOnException(ContextManager[T]): pass
print(FailOnException.__mro__)
(<class '__main__.FailOnException'>, <class 'contextlib.AbstractContextManager'>, <class 'abc.ABC'>, <class 'typing.Generic'>, <class 'object'>)
- Dominant language
- Python
- Stars
- 1.1k
- Forks
- 147
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 39
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from PyCQA/flake8-bugbear
-
Difficulty 3/5 1-2 days Newbie friendliness 44/100
PyCQA/flake8-bugbear#620 · 4 comments ·
Maintainers usually reply within 2 days
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
PyCQA/flake8-bugbear#536 ·
Maintainers usually reply within 2 days
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
PyCQA/flake8-bugbear#492 · 3 comments ·
Maintainers usually reply within 2 days
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
PyCQA/flake8-bugbear#467 · 7 comments · 1 reaction ·
Maintainers usually reply within 2 days
-
B909 improvementsOpen
Difficulty 5/5 Over a week Newbie friendliness 25/100
PyCQA/flake8-bugbear#454 · 4 comments · 1 reaction ·
Maintainers usually reply within 2 days
All issues in PyCQA/flake8-bugbear
Similar issues
-
bug
Difficulty 1/5 Under an hour Newbie friendliness 85/100
NatLabRockies/openstudio-mcp#286 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
intersystems/ipm#1338 ·
Maintainers usually reply within 1 day
-
separate_packages splits imports from the same explicitly configured packagePossibly taken @rahul05ranjan claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 2 days
-
The v0-through-v1 path derives ShutdownDuration its own way, silently overriding a user's definitionOpenv1
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Maintainers usually reply within 1 day