Skip to content
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

Do Not Remove Newline Following docstring in Stub Functions #154

Closed
weibullguy opened this issue Jan 20, 2023 · 0 comments · Fixed by #171
Closed

Do Not Remove Newline Following docstring in Stub Functions #154

weibullguy opened this issue Jan 20, 2023 · 0 comments · Fixed by #171
Labels
C: style Relates to docstring format style (e.g., Google, NumPy, Sphinx) P: enhancement Feature that is outside the scope of PEP 257 S: merged Closed with work merged to repository
Milestone

Comments

@weibullguy
Copy link
Member

In functions and methods with only a docstring, it is stylistically considered redundant to include a pass statement. See the pylint issue requesting the Unnecessary pass warning. However, PEP257 states, "There’s no blank line either before or after the docstring." Thus, in the following code snippet, the newline before the second function will be removed by docformatter which causes pylint to raise the W0107 warning (see here).

def a_function():
    """Here we have a stub function that does ugatz."""

def b_function():
    """Here we have the next function separated from the first by a newline.

    We want the newline to remain in place, but currently docformatter
    removes it because it sees the def statement as the next line of code.
    """

Currently, including a pass statement in a_function will cause docformatter to retain the newline, However, docformatter should recognize a_function as a stub and retain the newline without the use of a pass statement.

@weibullguy weibullguy added P: enhancement Feature that is outside the scope of PEP 257 C: style Relates to docstring format style (e.g., Google, NumPy, Sphinx) labels Jan 20, 2023
@github-actions github-actions bot added the fresh This is a new issue label Jan 20, 2023
@weibullguy weibullguy removed the fresh This is a new issue label Jan 20, 2023
@weibullguy weibullguy added this to the v2.0.0 milestone Jan 23, 2023
@weibullguy weibullguy modified the milestones: v2.0.0, v1.7.0 Mar 20, 2023
@weibullguy weibullguy added the S: merged Closed with work merged to repository label Apr 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: style Relates to docstring format style (e.g., Google, NumPy, Sphinx) P: enhancement Feature that is outside the scope of PEP 257 S: merged Closed with work merged to repository
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant