PyCQA / PyCQA/flake8-bugbear

Error message for B005 is not precise enough

Open
#91 1 comment 5 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

Using .strip() with multi-character strings is misleading the reader. It looks like stripping a substring. Move your character set to a constant if this is deliberate. Use .replace() or regular expressions to remove string fragments.

It says that you shouldn't pass strings with multiple characters as .strip() arguments - but actually, the rule does not restrict any multiple characters string, only those with repeatable characters.

So, for example, argument .strip('abc') is fine, but .strip('aaa') is not. And tests represent it.

Probably, it would be better to rephrase rule message a bit?

P.S. And, speaking of tests: in module with test cases for this rule comment near the case s.rstrip("we") says that there will be warning, while actually it won't be.

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 with the B005 rule implementation and its test cases, especially the cases covering repeatable characters and s.rstrip("we"). Confirm the diagnostic wording matches the rule’s actual behavior and correct the misleading test comment; run the B005 tests to verify the message and cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.