-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Enforce empty lines before classes/functions with sticky leading comments. #3302
Conversation
diff-shades results comparing this PR (36ae752) to main (575220f). The full diff is available in the logs under the "Generate HTML diff report" step.
|
I pushed a few new commits to address a few unexpected diffs from diff-shades. I read through the latest diff-shades results again, and they look all expected. |
…ment but after decorators.
Co-authored-by: Jelle Zijlstra <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a ton! Some comments below, and one discussion point: would it make sense to consider the comments to be in the block? Instead of having an outer "semantic comment" I'm not 100 % sure, but that could simplify things so that we can use ordinary newline rules for the whole block. Maybe? 🤔
This is appealing. But I tried and couldn't yet find a way to actually simplify this by considering the comments to be in the block. To decide whether a comment belongs to this block, we have to examine what the block is, as well as the newlines in the first leaf prefix. This logic is already part of EmptyLineTracker. So this would require a big surgery to redesign EmptyLineTracker and likely also the LineGenerator. All the empty line logic is still contained inside the EmptyLineTracker, so I feel this PR's implementation isn't too bad. |
PR updated to keep the current behavior for inner functions after code block open. This now only fixes #246. |
This aligns code with psf/black#3302 Depends-On: https://review.opendev.org/866943 Change-Id: Icfbca2fab8adeb677b980d01f797f194f580838e
* Update adjutant from branch 'master' to 6b1856b4eb43f56010988fd464d3077de5c765fd - Support tox4, update style to match Black 23.1a1 This aligns code with psf/black#3302 Depends-On: https://review.opendev.org/866943 Change-Id: Icfbca2fab8adeb677b980d01f797f194f580838e
See psf/black#3302 for details. Fixes: #37 Signed-off-by: Stanislav Levin <[email protected]>
See psf/black#3302 for details. Fixes: #37 Signed-off-by: Stanislav Levin <[email protected]>
See psf/black#3302 for details. Fixes: #37 Signed-off-by: Stanislav Levin <[email protected]>
Once upon a time black and pydocstyle disagreed on blank lines before nested functions, and a comment would appease them both. Since then, the latter has been changed to not complain about a blank line (PyCQA/pydocstyle#426), and the former now complains about the missing blank line even with the comment (psf/black#3302).
Once upon a time black and pydocstyle disagreed on blank lines before nested functions, and a comment would appease them both. Since then, the latter has been changed to not complain about a blank line (PyCQA/pydocstyle#426), and the former now complains about the missing blank line even with the comment (psf/black#3302).
Once upon a time black and pydocstyle disagreed on blank lines before nested functions, and a comment would appease them both. Since then, the latter has been changed to not complain about a blank line (PyCQA/pydocstyle#426), and the former now complains about the missing blank line even with the comment (psf/black#3302).
Once upon a time black and pydocstyle disagreed on blank lines before nested functions, and a comment would appease them both. Since then, the latter has been changed to not complain about a blank line (PyCQA/pydocstyle#426), and the former now complains about the missing blank line even with the comment (psf/black#3302).
Description
Enforce empty lines before classes/functions with leading comments:
EmptyLineTracker
works on lines that haven't been split yet. When sticky leading comment is used before class/def lines, the tracker must look behind the possible comment lines. So I introduced a newLinesBlock
class to keep track of those states.Checklist - did you ...
CHANGES.md
if necessary?