Derived from the flake8-bugbear linter.
What it does#
Checks for uses of multi-character strings in
Why is this bad?#
All characters in the call to
removed from the leading and trailing ends of the string. If the string
contains multiple characters, the reader may be misled into thinking that
a prefix or suffix is being removed, rather than a set of characters.
In Python 3.9 and later, you can use
str.removesuffix to remove an exact prefix or suffix from a string,
respectively, which should be preferred when possible.
As a heuristic, this rule only flags multi-character strings that contain
duplicate characters. This allows usages like
removes all occurrences of the characters
z from the
leading and trailing ends of the string, but not
The use of unique, multi-character strings may be intentional and
consistent with the intent of
while the use of duplicate-character strings is very likely to be a