-
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
Two blank lines after an import should be reduced to one #4489
base: main
Are you sure you want to change the base?
Two blank lines after an import should be reduced to one #4489
Conversation
I got an email about this job failure but looks like all the checks are passing on the PR https://github.com/psf/black/actions/runs/11377698063/job/31652281800 is this something that needs to be addressed? |
Interesting, I suspect some change to how GitHub handles artifacts. Not sure why it doesn't show up here. |
I got this same error again on the rerun of the workflows https://github.com/psf/black/actions/runs/11483099904/job/31957735676 and seems to be because there's no artifact in this workflow https://github.com/psf/black/actions/runs/11412528080 with the file name https://github.com/psf/black/blob/main/.github/workflows/diff_shades.yml#L130:
|
hey @JelleZijlstra ! :) just bumping this PR - do the changes look good or are there other modifications you'd like to see? |
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, this looks reasonable
One nit: could you move the logic down next to
Lines 674 to 680 in c98fc0c
if ( | |
self.previous_line.is_import | |
and not current_line.is_import | |
and not current_line.is_fmt_pass_converted(first_leaf_matches=is_import) | |
and depth == self.previous_line.depth | |
): | |
return (before or 1), 0 |
@hauntsaninja for sure, let me know if where I moved the logic is what you were thinking! also moved all the case cases to a single file, added a test case for imports inside a function, and expanded some existing test cases |
Description
Hey! Trying to contribute for the first time to the project so let me know if I'm missing anything :)
I've implemented changes to address this issue #2020 where there's some inconsistency around how many lines are added after an import. I've added 2 test cases showing that if there is more than 1 blank line between the import and the next line that it is now being reduced to one. One test case was failing because it had in its expected outout 2 lines between the import and following statement, so I think modifying the test case now that it should always be one makes sense.
Checklist - did you ...
CHANGES.md
if necessary?