Repository navigation
B005: mention repeated characters in the message - #587
Merged
Merged
Conversation
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
Contributor
There was a problem hiding this comment.
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
approved these changes
Oct 7, 2026
cooperlees
left a comment
Collaborator
There was a problem hiding this comment.
Thanks - this will help people. I don't think we must have all the different strips in the message.
# Conflicts: # README.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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) andpre-commit run --all-files.