-
Notifications
You must be signed in to change notification settings - Fork 67
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
Empty lines around class and method docstrings #130
Comments
FYI, modifying the if statement in format.py with the following seems to fix blank lines preceding method and class docstrings, if (
len(modified_tokens) <= 2
or token_type not in {tokenize.NL, tokenize.NEWLINE}
or modified_tokens[-1][0]
not in {tokenize.NL, tokenize.NEWLINE}
or modified_tokens[-2][1] != ":"
and modified_tokens[-2][0] != tokenize.COMMENT
or not modified_tokens[-2][4].lstrip().startswith(("def", "class"))
): |
What is the intended behaviour in the case below? class Foo:
def foo(self):
pass In my interpretation, this is fine. But with the latest version of docformatter (1.5.1) this gets formatted as: class Foo:
def foo(self):
pass The result is that docformatter is now incompatible with the defaults for yapf ( Edit: I see this is already addressed in #142 👍 |
what about this case? it removes all spaces and I think it shouldn't... 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" When using it with |
It would be nice if docformatter added/removed blank lines around the docstrings of classes and methods. According to the pep257 and numpy conventions, there should be no blank lines either before or after method docstrings and classes should have a blank line after their docstring but not before.
This issue is pretty much the same as #51 but applied to classes and methods.
Thus, the following,
should be reformatted as,
The text was updated successfully, but these errors were encountered: