-
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
Document experimental string processing and docstring indentation #2106
Conversation
Self-review! So I had a look over the issue tracker, and #1740 implies the existence of further docstring processing (i.e. stripping white space), but I couldn't find the original source. I did find the original Docstring opinion issue, and several by Jelle fixing crashes on docstring modifications like removing trailing whitespace. But I got pretty lost pretty quickly. Should we just add a mention about stripping white space? Alternatively, #1740 (or a follow-up PR) could add all the information about docstring contents. I think the long-term solution to closing #53 could be to add a section to |
Did you try looking at the test cases for docstrings? That's probably the best way to find out all the things we change. I believe it's mostly about reindentation and stripping whitespace. Also, thanks for contributing this! I'll take a more detailed look later. |
Yep, the docstring formatting Black does mostly boils down to reindenting and stripping whitespace, but there is an edge case where Black does move the quotes: ichard26@acer-ubuntu:~/programming/oss/black$ cat test.py
def test8():
"""Or like this.
"""
ichard26@acer-ubuntu:~/programming/oss/black$ black test.py --diff -q
--- test.py 2021-04-14 22:59:18.638257 +0000
+++ test.py 2021-04-14 22:59:33.679733 +0000
@@ -1,3 +1,2 @@
def test8():
- """Or like this.
- """
+ """Or like this.""" This behaviour does have a report: #1635 but it's unclear whether this should exist (and therefore be documented) (@JelleZijlstra I'm personally of the opinion we should get consistent about this by either uniformingly moving quotes or not moving them at all)
I am leaning towards letting the proposed PRs add the information on docstring reformatting just in case we reject one (seems unlikely but always a possibility), but I don't feel strongly about this.
Yeah I agree to add such a section in the contributing documentation (I'll probably end up doing it myself). In terms enforcing it automatically... yeah it would difficult to do that. I do want to write PR review documentation though, so I suppose we could mention checking for this there.
One, that certainly shouldn't happen regardless of the platform and sounds like a bug. And two, is it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other than the docstring docs being incorrect I can't find anything to fault your documentation on.
Has the processing changed since?
Other than a lot of bugfixes, no IIRC the processing hasn't changed.
RE: Doc placement
I agree with your reasoning and I'm happy with where it is as of right now.
Excellent work and thank you for picking this up! I'll leave this for Jelle to review.
Oh you're totally right! What an oversight 😅
It occured while Blackening with pre-commit for the first time (but does reproduce with it now too). It's an access denied on |
Sorry about the force noise 😅 I got a bit carried away with small details. I squashed the changes into the two commits, so you can choose if you'd like to separate the commits in |
Heya once more! With the closing of #1740, I added its style description to this PR, and added a missing test to validate that completely empty docstrings get the space inserted too. Ready if you are! |
Thank you! |
From #53: this PR adds short descriptions of #1053 and #1132 to the Black code style document.
Possible points of review/contention:
I don't think any of the checks apply, and
skip news
could also be added. Pre-commit did line up the text though.Happy to make any changes you suggest!
Also, while running the install stuff, there was some sort of process pool termination when formatting the repository. Is that something that is expected to happen on Windows?