How to force blank line after function docstring (D202) #7230
Replies: 1 comment 5 replies
-
I briefly tried to use the pydocstyle formatter, and even explicitly using the I see this has been closed as outdated, but I could not find any solution: is it still impossible to opt for a different behaviour? My [lint.pydocstyle]
convention = "pep257" Sample Python source: """
This is a top-level docstring.
It explains what the module does.
"""
class Class:
"""
This is the docstring of a specific class.
It explains the purpose of the class, and introduces it significant entry-points.
"""
CONST: int = 0
"""
This is the docstring of a class attribute.
"""
def method(self) -> None:
"""
This is the docstring of a method of the class.
It should tell what the method does, list its arguments and their meaning.
"""
return None
def function(a: int, b: str) -> str:
"""
This is the docstring for a function.
It should mention `a` and `b` and tell that it returns their multiplication.
"""
return b * a Output of --- foo.py
+++ foo.py
@@ -23,7 +23,6 @@
It should tell what the method does, list its arguments and their meaning.
"""
-
return None
@@ -33,5 +32,4 @@
It should mention `a` and `b` and tell that it returns their multiplication.
"""
-
return b * a
Would fix 2 errors. |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Rule D202 prevents any blank lines after function docstrings, however I find it easier to read when a single blank line is there. Similar to choosing D211/D203 is there a rule or configuration I could change to enforce a single blank line (rather than just turning the rule off)
X-Posted to Discord help channel forum (https://discord.com/channels/1039017663004942429/1149497948363825302)
Beta Was this translation helpful? Give feedback.
All reactions