PyCharm does not strip trailing whitespaces in docstrings

Answered

I'm running PyCharm since 2016.3 and I don't recall having this issue at the beginning. I'm now at 2017.1.2 and PyCharm does not strip trailing whitespaces within Python's docstrings.

As you can see in the above screenshot trailing whitespaces in the function body are stripped as expected but not the ones in the docstring.

My settings are set to strip trailing spaces on modified lines only but still, this is not the expected behavior.

8 comments
Comment actions Permalink

Hi Jimmy! I am very sorry for the inconvenience. It's a known regression problem https://youtrack.jetbrains.com/issue/PY-23453 and is fixed in 2017.1.3 EAP, would you mind trying Release Candidate build?

2
Comment actions Permalink

@pavel I'm still having problems with this in 2017.1.4 (any line inside triple quotes does not get trimmed)

 

Any ideas why?

0
Comment actions Permalink

Hi Eli! Could you please specify what option do you have in Editor | General | Strip trailing spaces on Save? Do all lines inside string literals affected? Are not this literals raw (e.g. r"""hello world""")?

0
Comment actions Permalink

It still doesnt trim them.

 

Editor | General | Strip trailing spaces on Save is set to 'all'.

 

PyCharm 2018.2.1 (Community Edition)
Build #PC-182.3911.33, built on August 5, 2018
JRE: 1.8.0_152-release-1248-b8 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 7 6.1

0
Comment actions Permalink

Hi, make sure caret isn't placed on the line with the trailing spaces, by default it is ignored (see Editor | General | Always keep trailing spaces on caret line). Also please disable Editor | Code Style | EditorConfig support. Has it helped?

0
Comment actions Permalink

Hi, I'm still having this problem with triple quoted strings('''). I have "strip trailing spaces" set to "All" and uncheked "Always Keep trailing spaces on caret line". I'm using PyCharm 2019.3

0
Comment actions Permalink

Hi Francisco, could you please create a ticket in PyCharm's bug tracker https://youtrack.jetbrains.com/issues/PY and provide expected/actual details?

0
Comment actions Permalink

Hi Pavel, there's already an issue for this:

https://youtrack.jetbrains.com/issue/PY-23871

 

Although I think it's a bug and not an improvement

0

Please sign in to leave a comment.