Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,9 @@ results. Use ``callable(x)`` for consistent results.

.. _B005:

**B005**: Using ``.strip()`` with multi-character strings is misleading
the reader. It looks like stripping a substring. Move your
**B005**: Using ``.strip()`` with a multi-character string that repeats
characters is misleading the reader. It looks like stripping a substring,
but the argument is treated as a set of characters. Move your
character set to a constant if this is deliberate. Use
``.replace()``, ``.removeprefix()``, ``.removesuffix()`` or regular
expressions to remove string fragments.
Expand Down Expand Up @@ -528,6 +529,8 @@ UNRELEASED

* B045: detect reuse of an enclosing loop's control variable in a nested loop
in the same scope (#360).
* B005: say in the message that only strings with repeated characters are
reported, since ``.strip("abc")`` style character sets are fine (#91)
* B031: only treat a bare ``groupby()`` call as ``itertools.groupby`` when the
module doesn't bind ``groupby`` to something else, such as its own
``def groupby`` (#356)
Expand Down
7 changes: 4 additions & 3 deletions bugbear.py
Original file line number Diff line number Diff line change
Expand Up @@ -3183,9 +3183,10 @@ def __call__(self, lineno: int, col: int, vars: tuple[object, ...] = ()) -> erro
),
"B005": Error(
message=(
"B005 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 "
"B005 Using .strip() with a multi-character string that repeats "
"characters is misleading the reader. It looks like stripping a "
"substring, but the argument is treated as a set of characters. "
"Move your character set to a constant if this is deliberate. Use "
".replace(), .removeprefix(), .removesuffix(), or regular "
"expressions to remove string fragments."
)
Expand Down
Loading