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

blank-line-between-methods (E301) & blank-lines-top-level (E302) - conflicts with formatter on .pyi files #10039

Closed
DetachHead opened this issue Feb 19, 2024 · 2 comments · Fixed by #10098
Labels
bug Something isn't working help wanted Contributions especially welcome preview Related to preview mode features

Comments

@DetachHead
Copy link

# foo.pyi
class Foo: ...
class Bar: ... # error: Expected 2 blank lines, found 0

when running ruff format on this file, it removes the additional blank lines that E302 expects

@MichaReiser MichaReiser added bug Something isn't working preview Related to preview mode features labels Feb 19, 2024
@MichaReiser
Copy link
Member

Nice find. We should review all the E3* rules and verify that they enforce at most one blank lines for pyi files rather than 2

@DetachHead DetachHead changed the title blank-lines-top-level (E302) - conflicts with formatter on .pyi files blank-line-between-methods (E301) & blank-lines-top-level (E302) - conflicts with formatter on .pyi files Feb 19, 2024
@KotlinIsland
Copy link
Contributor

I've also detected E305 blank-lines-after-function-or-class also conflicts

@MichaReiser MichaReiser added the help wanted Contributions especially welcome label Feb 20, 2024
MichaReiser added a commit that referenced this issue Mar 5, 2024
…`) (#10098)

## Summary

Fixes #10039

The [recommendation for typing stub
files](https://typing.readthedocs.io/en/latest/source/stubs.html#blank-lines)
is to use **one** blank line to group related definitions and
otherwise omit blank lines. 

The newly added blank line rules (`E3*`) didn't account for typing stub
files and enforced two empty lines at the top level and one empty line
otherwise, making it impossible to group related definitions.

This PR implements the `E3*` rules to:

* Not enforce blank lines. The use of blank lines in typing definitions
is entirely up to the user.
* Allow at most one empty line, including between top level statements. 

## Test Plan

Added unit tests (It may look odd that many snapshots are empty but the
point is that the rule should no longer emit diagnostics)
nkxxll pushed a commit to nkxxll/ruff that referenced this issue Mar 10, 2024
…`) (astral-sh#10098)

## Summary

Fixes astral-sh#10039

The [recommendation for typing stub
files](https://typing.readthedocs.io/en/latest/source/stubs.html#blank-lines)
is to use **one** blank line to group related definitions and
otherwise omit blank lines. 

The newly added blank line rules (`E3*`) didn't account for typing stub
files and enforced two empty lines at the top level and one empty line
otherwise, making it impossible to group related definitions.

This PR implements the `E3*` rules to:

* Not enforce blank lines. The use of blank lines in typing definitions
is entirely up to the user.
* Allow at most one empty line, including between top level statements. 

## Test Plan

Added unit tests (It may look odd that many snapshots are empty but the
point is that the rule should no longer emit diagnostics)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Contributions especially welcome preview Related to preview mode features
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants