B011 is misleading, and the advice doesn't sound good
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.1k
- Forks
- 123
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 5
Description
B011 Do not call assert False since python -O removes these calls. Instead callers should raise AssertionError().
There are two problems with this:
- Removal of assertions with
-Ois not limited toassert Falsecases, it removes all assertions. So the message is misleading. - The suggestion to replace this assert with
raise AssertionError()is not a good one, because such a construct cannot be disabled by disabling assertions when one explicitly wants to do that.
Given these considerations, I cannot think of a good use case or a fix for B011 in the first place, so I suggest removing it altogether.
Contributor guide
No contributing guide indexed for this repository
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.
Research direction
Start by locating the B011 implementation and any tests for it in flake8-bugbear. Compare them with the issue’s two objections about Python -O and raise AssertionError(). Done means resolving whether B011 should be removed and updating the affected behavior and tests accordingly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100