Format empty lines in stub files like black's preview style#7206
Merged
Format empty lines in stub files like black's preview style#7206
Conversation
db5de5d to
76244b7
Compare
d39b8ee to
64ee983
Compare
konstin
commented
Sep 8, 2023
Comment on lines
+132
to
+135
| (PySourceType::Stub, NodeLevel::TopLevel) => 1, | ||
| (PySourceType::Stub, _) => 0, | ||
| (_, NodeLevel::TopLevel) => 2, | ||
| (_, _) => 1, |
Member
Author
There was a problem hiding this comment.
it's a bit counterintuitive that the exceptions are the named cases
Member
There was a problem hiding this comment.
Should empty_lines be inlined into empty_lines_before_trailing_comments. It seems the function is only used in stmt_function_def and stmt_class_def and both use the same implementation.
d656154 to
52a7ff9
Compare
52a7ff9 to
2589e1a
Compare
MichaReiser
approved these changes
Sep 11, 2023
Comment on lines
+132
to
+135
| (PySourceType::Stub, NodeLevel::TopLevel) => 1, | ||
| (PySourceType::Stub, _) => 0, | ||
| (_, NodeLevel::TopLevel) => 2, | ||
| (_, _) => 1, |
Member
There was a problem hiding this comment.
Should empty_lines be inlined into empty_lines_before_trailing_comments. It seems the function is only used in stmt_function_def and stmt_class_def and both use the same implementation.
Co-authored-by: Micha Reiser <micha@reiser.io>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix all but one empty line differences with the black preview style in typeshed. The remaining differences are breaking with type comments and trailing commas in function definitions.
I compared the empty line differences with the preview mode of black since stable has some oddities that would have been hard to replicate (psf/black#3861). Additionally, it assumes the style proposed in psf/black#3862.
An edge case that also surfaced with typeshed are newline before trailing module comments.
main
PR
Closes #6723
Test Plan
The main driver was the typeshed diff. I added new test cases for all kinds of possible empty line combinations in stub files, test cases for newlines before trailing module comments.