D202: Incompatibility with black 23
adamjstewart opened this issue · 2 comments
adamjstewart commented
Black 23.1.0 introduces a new formatting change that requires an empty line before functions: psf/black#3302. In some rare cases, this seems to counteract pydocstyle requirements.
Steps to reproduce
- Create the following file:
"""Foo.""" def foo(): """Foo.""" # Closure def bar(): """Bar.""" pass
- Run pydocstyle, see that it passes
- Run black, see that it inserts a newline before the comment
--- foo.py 2023-02-01 22:01:42.684243 +0000 +++ foo.py 2023-02-01 22:02:23.613704 +0000 @@ -1,9 +1,10 @@ """Foo.""" def foo(): """Foo.""" + # Closure def bar(): """Bar.""" pass
- Run pydocstyle again, see that it fails:
foo.py:5 in public function `foo`: D202: No blank lines allowed after function docstring (found 1)
It's unclear to me whether black or pydocstyle is in the wrong here. Since black is a bigger project, I thought I'd start here and see whether pydocstyle should conform to this new standard set by black or whether this is a bug I should report to black.
adamjstewart commented
Note that the issue disappears if the comment is removed. Black still reformats the function, but pydocstyle is okay with it with or without the newline. This leads me to believe this is a problem with pydocstyle.