-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
bugSomething isn't workingSomething isn't workingdocstringRelated to docstring linting or formattingRelated to docstring linting or formatting
Description
For the following code:
def outer():
"""This is a docstring."""
# This is a comment.
def inner():
return
return innerI see the following behaviour:
❯ ruff --version
ruff 0.0.240
❯ ruff --select D202 bug.py
# ... no output ...
❯ black --version
black, 23.1.0 (compiled: yes)
Python (CPython) 3.10.9
❯ black --diff bug.py
--- bug.py 2023-02-05 21:19:16.413892 +0000
+++ bug.py 2023-02-05 21:19:22.497046 +0000
@@ -1,7 +1,8 @@
def outer():
"""This is a docstring."""
+
# This is a comment.
def inner():
return
return inner()
would reformat bug.py
All done! ✨ 🍰 ✨
1 file would be reformatted.
❯ black bug.py
reformatted bug.py
All done! ✨ 🍰 ✨
1 file reformatted.
❯ ruff --select D202 bug.py
bug.py:2:5: D202 No blank lines allowed after function docstring (found 1)
Found 1 error.
1 potentially fixable with the --fix option.It seems that this works fine if the comment is removed. Black wants a blank line before and after a nested function. But black treats comment lines before the function as "attached" to the function. This doesn't happen with the D202 rule in ruff which treats them as separate. We should follow black's lead here.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingdocstringRelated to docstring linting or formattingRelated to docstring linting or formatting