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

Ruff rule does not describe multiple rules #5495

Closed
rotu opened this issue Jul 3, 2023 · 7 comments · Fixed by #5511
Closed

Ruff rule does not describe multiple rules #5495

rotu opened this issue Jul 3, 2023 · 7 comments · Fixed by #5511
Labels
bug Something isn't working

Comments

@rotu
Copy link

rotu commented Jul 3, 2023

version = 0.0.272

Flake8 supports providing a partial error code like "E4" to select all error codes starting with "E4" (i.e. E401 and E402)

ruff . --select E4 runs both E401 and E402.
But ruff rule E4 describes E401 and does not even mention that "E4" also entails E402.

@rotu
Copy link
Author

rotu commented Jul 3, 2023

Behavior has changed since #2812 was reported. Not sure if current behavior is intentional.

@charliermarsh charliermarsh added the bug Something isn't working label Jul 3, 2023
@charliermarsh
Copy link
Member

My initial preference would be to error on ruff rule E4, rather than show multiple rules, since we don't really have a good format for that. At the very least, it's wrong to show the E402 docs in that case!

@rotu
Copy link
Author

rotu commented Jul 4, 2023

@charliermarsh erroring would be good. Even better would be showing the list of rules it expands to (just the ID and short name is plenty useful!)

@dhruvmanila
Copy link
Member

The behavior got changed in 0.0.247, earlier we were throwing an error:

pipx run "ruff==0.0.246" rule E4                               
⚠️  ruff is already on your PATH and installed at /Users/dhruv/.local/bin/ruff. Downloading and running anyway.
error: invalid value 'E4' for '<RULE>': unknown rule code

For more information, try '--help'.

I think it might be related to the many-to-one changes: git log --grep='^many-to-one' --oneline

@charliermarsh
Copy link
Member

@dhruvmanila - Are you taking a look at the lack of an error?

@dhruvmanila
Copy link
Member

You can look at it if you want, I just thought to perform a quick bisection search to find out when did the behavior changed.

@charliermarsh
Copy link
Member

I'll take a quick look.

charliermarsh added a commit that referenced this issue Jul 4, 2023
Closes #5495, but there's a TODO here to improve this further. The
current `from_code` implementation feels really indirect.
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
Development

Successfully merging a pull request may close this issue.

3 participants