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

explicit-preview-rules does not work for fixes #9282

Closed
hauntsaninja opened this issue Dec 26, 2023 · 1 comment · Fixed by #9538
Closed

explicit-preview-rules does not work for fixes #9282

hauntsaninja opened this issue Dec 26, 2023 · 1 comment · Fixed by #9538
Assignees
Labels
bug Something isn't working

Comments

@hauntsaninja
Copy link
Contributor

hauntsaninja commented Dec 26, 2023

I'd expect both runs of ruff below to fix the error

~/tmp/repro λ ruff --version
ruff 0.1.9

~/tmp/repro λ cat asdf.py
lists = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
sum(lists, [])
~/tmp/repro λ cat pyproject.toml
[tool.ruff]
select = ["RUF017"]
[tool.ruff.lint]
preview = true
explicit-preview-rules = true
~/tmp/repro λ ruff asdf.py --fix --unsafe-fixes
asdf.py:2:1: RUF017 Avoid quadratic list summation
Found 1 error.

~/tmp/repro λ vim pyproject.toml
~/tmp/repro λ cat pyproject.toml
[tool.ruff]
select = ["RUF017"]
[tool.ruff.lint]
preview = true
~/tmp/repro λ ruff asdf.py --fix --unsafe-fixes
Found 1 error (1 fixed, 0 remaining).
@hauntsaninja hauntsaninja changed the title explicit-preview-rules does not work for rules explicitly selected on command line explicit-preview-rules does not work for fixes Dec 26, 2023
@zanieb
Copy link
Member

zanieb commented Dec 26, 2023

Thanks for the report! My assumption is that the fixable setting which defaults to ALL is not including the preview rule since it is not explicit. We should probably exempt fixable from these semantics.

@zanieb zanieb added the bug Something isn't working label Dec 26, 2023
@charliermarsh charliermarsh self-assigned this Jan 15, 2024
charliermarsh added a commit that referenced this issue Jan 16, 2024
## Summary

Right now, if you run with `explicit-preview-rules`, and use something
like `select = ["RUF017"]`, we won't actually enable fixing for that
rule, because `fixable = ["ALL"]` (the default) won't include `RUF017`
due to the `explicit-preview-rules`.

The framing in this PR is that `explicit-preview-rules` should only
affect the enablement selectors, whereas the fixable selectors should
just include all possible matching rules. I think this will lead to the
most intuitive behavior.

Closes #9282. (An alternative to
#9284.)
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
3 participants