-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Be more careful with docstrings ending with quotes + whitespace #1455
Conversation
45a7168
to
6351989
Compare
Thanks for your contribution! I would personally prefer we leave the space in instead of backslash-escaping the quote. That's more in line with Black's general principle of avoiding backslashes and it matches the original formatting of the real-world examples in #1452. Would that be easy to implement instead? |
I can take a gander; your #1417 seemed to move in the direction of formalizing the whitespace change, however, so I figured this was merely a bugfix on that behaviour. |
Here's an alternate commit which moves toward preserving the contents more unchanged. Happy to push this to the branch if this is preferred.
|
The PEP 257 algorithm used in psf#1053 results in trimming trailing whitespace in docstrings -- see psf#1415. Adjust the algorithm to preserve leading and trailing whitespace; this reverts the changes in psf#1417. This diverges from PEP 257, but better retains the contents of the docstring. Fixes psf#1452 because we no longer can end up with four trailing quotes.
`visit_STRING` finishes by calling `visit_default`, which already deals with calling `normalize_string_quotes` -- and correctly checks for `self.normalize_strings` first, which this callsite does not.
6351989
to
8b28bc1
Compare
I can't replicate the Primer failures. On MacOS with Python 3.7.8, black-primer runs to completion just fine:
|
Primer is still a bit flaky, it's fine in this case as you've have done a local run that has passed. |
The PEP 257 algorithm used in #1053 results in trimming trailing
whitespace in docstrings -- see #1415.
Adjust the algorithm to preserve leading and trailing whitespace; this
reverts the changes in #1417. This diverges from PEP 257, but better
retains the contents of the docstring.
Fixes #1452 because we no longer can end up with four trailing quotes.