Skip to content

B005: mention repeated characters in the message - #587

Merged
cooperlees merged 2 commits into
PyCQA:mainfrom
LuisFigueroaG:fix/b005-message
Oct 7, 2026
Merged

cooperlees merged 2 commits into
PyCQA:mainfrom
LuisFigueroaG:fix/b005-message

Conversation

@LuisFigueroaG

@LuisFigueroaG LuisFigueroaG commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

B005 only fires when the string passed to .strip()/.lstrip()/.rstrip() repeats a character (.strip("abc") is fine, .strip(".facebook.com") isn't), but the message read as if any multi-character string was a problem. This rewords it to say what's actually reported and that the argument is treated as a set of characters. README text updated to match, plus a changelog entry.

The test comment mentioned in the issue (s.rstrip("we")) was already fixed at some point, so no test changes were needed.

Closes #91

Tested with pytest tests/test_bugbear.py (3.10, 3.12, 3.13, 3.14) and pre-commit run --all-files.

The check only reports multi-character strings where a character shows
up more than once, but the message read as if any multi-character
argument was a problem. Say what is actually reported and that the
argument is treated as a set of characters.

Closes PyCQA#91

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

B005 wording still omits .lstrip() and .rstrip() in the diagnostic and documentation.

Review effort: Lite
Findings: None

What changed in this PR

Updates B005 wording to clarify repeated-character strings and character-set semantics.

Changes:

  • Revised the B005 diagnostic message.
  • Updated README guidance and changelog.
File Summary
README.rst Updated B005 documentation and changelog.
bugbear.py Revised the B005 error message.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@cooperlees cooperlees left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks - this will help people. I don't think we must have all the different strips in the message.

@cooperlees
cooperlees merged commit d8c5796 into PyCQA:main Oct 7, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error message for B005 is not precise enough

3 participants