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

E303: missing detection #10374

Closed
spaceone opened this issue Mar 13, 2024 · 3 comments · Fixed by #10382
Closed

E303: missing detection #10374

spaceone opened this issue Mar 13, 2024 · 3 comments · Fixed by #10382
Labels
bug Something isn't working

Comments

@spaceone
Copy link
Contributor

E303 not detected for:

#



import foo


def bar() -> list[str]:
    pass

flake8 detects: :5:1: E303 too many blank lines (3)

@boolean-light
Copy link
Contributor

I have tried all errors from E301 to E306 with --preview option, but none of them worked.

@dhruvmanila
Copy link
Member

Thanks for the report.

From the implementation side, I guess this must be a bug in the order in which the check is performed:

if state.is_not_first_logical_line {
self.check_line(&logical_line, &state, prev_indent_length, diagnostics);
}

and the state is being updated:

if !logical_line.is_comment_only {
state.is_not_first_logical_line = true;

/cc @hoel-bagard

@dhruvmanila dhruvmanila added the bug Something isn't working label Mar 13, 2024
@hoel-bagard
Copy link
Contributor

I'll have a look at it, thanks for reporting the bug.

hoel-bagard added a commit to hoel-bagard/ruff that referenced this issue Mar 13, 2024
Ignoring all lines until the first logical line does not match the
behavior from pycodestyle.

Fixes astral-sh#10374
hoel-bagard added a commit to hoel-bagard/ruff that referenced this issue Mar 13, 2024
Ignoring all lines until the first logical line does not match the
behavior from pycodestyle.

Fixes astral-sh#10374
dhruvmanila pushed a commit that referenced this issue Mar 14, 2024
…blank lines rules (#10382)

## Summary

Ignoring all lines until the first logical line does not match the
behavior from pycodestyle. This PR therefore removes the `if
state.is_not_first_logical_line` skipping the line check before the
first logical line, and applies it only to `E302`.

For example, in the snippet below a rule violation should be detected on
the second comment and on the import.

```python
# first comment




# second comment




import foo
```

Fixes #10374

## Test Plan

Add test cases, update the snapshots and verify the ecosystem check output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
4 participants