PyCQA / PyCQA/flake8-bugbear

B011 is misleading, and the advice doesn't sound good

Open
#66 17 comments 8 reactions 0 assignees View on GitHub

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:

  1. Removal of assertions with -O is not limited to assert False cases, it removes all assertions. So the message is misleading.
  2. 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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.