Skip to content

Respect # noqa directives on __all__ openers#10798

Merged
charliermarsh merged 1 commit intomainfrom
charlie/nqa
Apr 6, 2024
Merged

Respect # noqa directives on __all__ openers#10798
charliermarsh merged 1 commit intomainfrom
charlie/nqa

Conversation

@charliermarsh
Copy link
Member

Summary

Historically, given:

__all__ = [  # noqa: F822
    "Bernoulli",
    "Beta",
    "Binomial",
]

The F822 violations would be attached to the __all__, so this # noqa would be enforced for all definitions in the list. This changed in #10525 for the better, in that we now use the range of each string. But these # noqa directives stopped working.

This PR sets the __all__ as a parent range in the diagnostic, so that these directives are respected once again.

Closes #10795.

Test Plan

cargo test

@github-actions
Copy link
Contributor

github-actions bot commented Apr 5, 2024

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

Formatter (stable)

✅ ecosystem check detected no format changes.

Formatter (preview)

✅ ecosystem check detected no format changes.

Copy link
Member

@AlexWaygood AlexWaygood left a comment

Choose a reason for hiding this comment

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

Nice, thanks for the fix!

@charliermarsh charliermarsh enabled auto-merge (squash) April 6, 2024 14:43
@charliermarsh charliermarsh merged commit 7fb5f47 into main Apr 6, 2024
@charliermarsh charliermarsh deleted the charlie/nqa branch April 6, 2024 14:51
Glyphack pushed a commit to Glyphack/ruff that referenced this pull request Apr 12, 2024
## Summary

Historically, given:

```python
__all__ = [  # noqa: F822
    "Bernoulli",
    "Beta",
    "Binomial",
]
```

The F822 violations would be attached to the `__all__`, so this `# noqa`
would be enforced for _all_ definitions in the list. This changed in
astral-sh#10525 for the better, in that we
now use the range of each string. But these `# noqa` directives stopped
working.

This PR sets the `__all__` as a parent range in the diagnostic, so that
these directives are respected once again.

Closes astral-sh#10795.

## Test Plan

`cargo test`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

suppression Related to supression of violations e.g. noqa

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ruff 0.3.5 not respecting directive for all lines of a multiline expression

2 participants