-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Format empty lines in stub files like black's preview style #7206
Conversation
db5de5d
to
76244b7
Compare
d39b8ee
to
64ee983
Compare
(PySourceType::Stub, NodeLevel::TopLevel) => 1, | ||
(PySourceType::Stub, _) => 0, | ||
(_, NodeLevel::TopLevel) => 2, | ||
(_, _) => 1, |
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.
it's a bit counterintuitive that the exceptions are the named cases
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.
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
(PySourceType::Stub, NodeLevel::TopLevel) => 1, | ||
(PySourceType::Stub, _) => 0, | ||
(_, NodeLevel::TopLevel) => 2, | ||
(_, _) => 1, |
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.
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>
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.