Skip to content
This repository was archived by the owner on Nov 3, 2023. It is now read-only.
This repository was archived by the owner on Nov 3, 2023. It is now read-only.

D202: Incompatibility with black 23 #627

Open
@adamjstewart

Description

@adamjstewart

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

  1. Create the following file:
    """Foo."""
    
    
    def foo():
        """Foo."""
        # Closure
        def bar():
            """Bar."""
            pass
  2. Run pydocstyle, see that it passes
  3. 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
  4. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions