-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Re-indent the contents of docstrings
This uses the PEP 257 algorithm for determining docstring indentation, and adjusts the contents of docstrings to match their new indentation after `black` is applied. A small normalization is necessary to `assert_equivalent` because the trees are technically no longer precisely equivalent -- some constant strings have changed. When comparing two ASTs, whitespace after newlines within constant strings is thus folded into a single space.
- Loading branch information
Alex Vandiver
committed
Oct 10, 2019
1 parent
d9e71a7
commit 3c9f709
Showing
3 changed files
with
121 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
def foo(): | ||
"""This is a docstring with | ||
some lines of text here""" | ||
return | ||
|
||
|
||
def bar(): | ||
'''This is another docstring | ||
with more lines of text''' | ||
return | ||
|
||
|
||
def baz(): | ||
'''This is a string with some | ||
embedded "quotes"''' | ||
return | ||
|
||
|
||
def troz(): | ||
'''Indentation with tabs | ||
is just as OK''' | ||
return | ||
|
||
# output | ||
|
||
def foo(): | ||
"""This is a docstring with | ||
some lines of text here""" | ||
return | ||
|
||
|
||
def bar(): | ||
"""This is another docstring | ||
with more lines of text""" | ||
return | ||
|
||
|
||
def baz(): | ||
'''This is a string with some | ||
embedded "quotes"''' | ||
return | ||
|
||
|
||
def troz(): | ||
"""Indentation with tabs | ||
is just as OK""" | ||
return |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters