-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
[flake8-class-newline
] Add new flake8 plugin.
#10033
Conversation
c74ac56
to
9ebd2a4
Compare
9ebd2a4
to
1939eed
Compare
I don't really understand the compiling issue, in the test failure. |
/// PEP8 says we should surround every class method with a single blank line. | ||
/// However it is ambiguous about the first method having a blank line above it. | ||
/// This rule enforces a single blank line, for consistency across classes. |
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.
I think we should exclude pyi
files from this rule because empty lines in stub files should only be used for grouping methods.
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.
Done
CodSpeed Performance ReportMerging #10033 will degrade performances by 4.04%Comparing Summary
Benchmarks breakdown
|
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.
I took another look at the rule and, unfortunately, it is incompatible with our formatter that always removes empty lines between the class header and the first method.
Ruff doesn't have a good model to support formatter incompatible rules. The problem is that users using --select ALL
automatically opt in to the rule, and there's a good number of people using ALL
. We plan to resolve this by categorizing the rules. But we can't merge this rule until we figured the categorization out. I'm sorry
Ok no worries, appreciate the time. Should I close this PR, or keep it open for now? |
Summary
Add new flake8 plugin, flake8-class-newline which enforces a single blank line between a class definition and its first method.
Test Plan
Test cases have been added.