Skip to content

Commit 51d7111

Browse files
authored
Recommend .removeprefix() or .removesuffix() in B005 (#339)
1 parent 64d10cc commit 51d7111

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

README.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ results. Use ``callable(x)`` for consistent results.
8080
**B005**: Using ``.strip()`` with multi-character strings is misleading
8181
the reader. It looks like stripping a substring. Move your
8282
character set to a constant if this is deliberate. Use
83-
``.replace()`` or regular expressions to remove string fragments.
83+
``.replace()``, ``.removeprefix()``, ``.removesuffix()`` or regular
84+
expressions to remove string fragments.
8485

8586
**B006**: Do not use mutable data structures for argument defaults. They
8687
are created during function definition time. All calls to the function

bugbear.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1306,7 +1306,8 @@ def visit_Lambda(self, node):
13061306
"B005 Using .strip() with multi-character strings is misleading "
13071307
"the reader. It looks like stripping a substring. Move your "
13081308
"character set to a constant if this is deliberate. Use "
1309-
".replace() or regular expressions to remove string fragments."
1309+
".replace(), .removeprefix(), .removesuffix(), or regular "
1310+
"expressions to remove string fragments."
13101311
)
13111312
)
13121313
B005.methods = {"lstrip", "rstrip", "strip"}

0 commit comments

Comments
 (0)