diff --git a/doc/data/messages/b/bad-str-strip-call/bad.py b/doc/data/messages/b/bad-str-strip-call/bad.py new file mode 100644 index 0000000000..fe99b5e66b --- /dev/null +++ b/doc/data/messages/b/bad-str-strip-call/bad.py @@ -0,0 +1,2 @@ +my_string = "Hello World" +my_string.strip("Hello") # [bad-str-strip-call] diff --git a/doc/data/messages/b/bad-str-strip-call/details.rst b/doc/data/messages/b/bad-str-strip-call/details.rst new file mode 100644 index 0000000000..b2cc942d2a --- /dev/null +++ b/doc/data/messages/b/bad-str-strip-call/details.rst @@ -0,0 +1,7 @@ +A common misconception is that ``str.strip('Hello')`` removes the *substring* ``'Hello'`` from the beginning and end of the string. +This is **not** the case. +From the `documentation `_: + +> The chars argument is not a prefix or suffix; rather, all combinations of its values are stripped + +Duplicated characters in the ``str.strip`` call, besides not having any effect on the actual result, may indicate this misunderstanding. diff --git a/doc/data/messages/b/bad-str-strip-call/good.py b/doc/data/messages/b/bad-str-strip-call/good.py new file mode 100644 index 0000000000..cc566d5ff9 --- /dev/null +++ b/doc/data/messages/b/bad-str-strip-call/good.py @@ -0,0 +1,2 @@ +my_string = "Hello World" +my_string.strip("Helo") diff --git a/doc/data/messages/b/bad-str-strip-call/related.rst b/doc/data/messages/b/bad-str-strip-call/related.rst new file mode 100644 index 0000000000..db9ab44201 --- /dev/null +++ b/doc/data/messages/b/bad-str-strip-call/related.rst @@ -0,0 +1 @@ +- Documentation: `str.strip([chars]) `_