-
Notifications
You must be signed in to change notification settings - Fork 61
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
v1.6.0-rc2 - Emtpy Lines After Docstring and Before Nested Function Definition Are Removed #161
Comments
Per PEP-257, there is no blank line either before or after a docstring. The current docformatter behavior is correct. This is an enhancement that can be added to #94. |
I've added another example here: #130 (comment) Given: class Foo:
@abstractmethod
def bar(self):
"""This is a description."""
@abstractmethod
def baz(self):
"""This is a second description."""
def new_function():
"""Description."""
return "bar" I get this: class Foo:
@abstractmethod
def bar(self):
"""This is a description."""
@abstractmethod
def baz(self):
"""This is a second description."""
def new_function():
"""Description."""
return "bar" |
@bonastreyair per PEP-257, there is no blank line either before or after a docstring. Add a |
docformatter v1.6.0 isn't correctly removing the blank line after a docstring in this scenario; it's incorrectly removing the docstring between method definitions. PEP 257 states:
PEP 8 states:
docformatter shouldn't render an opinion on the use of the optional |
Note that this also applies to top level functions, not just class methods, e.g.
becomes
This is a pretty clear violation of pep8 (https://peps.python.org/pep-0008/#blank-lines)
I can't imagine that pep 257 was intended to override those basic pep8 blank line principles. |
@bonastreyair tag v1.6.1-rc1 should have the fix you need if you're interested in giving it a try before I officially release v1.6.1. @Kurt-von-Laven and @drasmuss you're correct, I didn't pay close enough attention to what @bonastreyair actually reported. Stub functions should be left as-is by docformatter in v1.6.1. |
v1.6.1-rc1 fixes this issue for me |
@weibullguy it works for mee too yup! thanks! |
#138 started removing empty lines after the method docstring including if the first code in the method if a function definition. I'm not sure if there should be exception for this situation...but at least
black
wants an empty line before a nested function definition.Example:
The text was updated successfully, but these errors were encountered: