Skip to content
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

Closed
wants to merge 11 commits into from

Conversation

augustelalande
Copy link
Contributor

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.

@augustelalande
Copy link
Contributor Author

I don't really understand the compiling issue, in the test failure.

Comment on lines +17 to +19
/// 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.
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link

codspeed-hq bot commented Feb 27, 2024

CodSpeed Performance Report

Merging #10033 will degrade performances by 4.04%

Comparing augustelalande:class_newline (4282d15) with main (8dc22d5)

Summary

❌ 1 regressions
✅ 29 untouched benchmarks

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Benchmarks breakdown

Benchmark main augustelalande:class_newline Change
linter/default-rules[large/dataset.py] 19.1 ms 19.9 ms -4.04%

Copy link
Member

@MichaReiser MichaReiser left a 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

@augustelalande
Copy link
Contributor Author

Ok no worries, appreciate the time. Should I close this PR, or keep it open for now?

@augustelalande augustelalande deleted the class_newline branch March 21, 2024 18:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants