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 --fix doesn't fix anything #4041

Closed
anentropic opened this issue Apr 20, 2023 · 6 comments
Closed

ruff --fix doesn't fix anything #4041

anentropic opened this issue Apr 20, 2023 · 6 comments

Comments

@anentropic
Copy link

$ ruff --version
ruff 0.0.262
$ ruff check --fix anetz
anetz/mappings.py:92:89: E501 Line too long (98 > 88 characters)
anetz/tools/evaluate.py:44:89: E501 Line too long (95 > 88 characters)
anetz/tools/evaluate.py:91:89: E501 Line too long (92 > 88 characters)
anetz/tools/evaluate.py:96:89: E501 Line too long (93 > 88 characters)
anetz/tools/evaluate.py:143:89: E501 Line too long (100 > 88 characters)
Found 5 errors.

$ ruff check --fix anetz
anetz/mappings.py:92:89: E501 Line too long (98 > 88 characters)
anetz/tools/evaluate.py:44:89: E501 Line too long (95 > 88 characters)
anetz/tools/evaluate.py:91:89: E501 Line too long (92 > 88 characters)
anetz/tools/evaluate.py:96:89: E501 Line too long (93 > 88 characters)
anetz/tools/evaluate.py:143:89: E501 Line too long (100 > 88 characters)
Found 5 errors.

I found the same with the VS Code plugin, it doesn't seem to do anything when you ask it to fix.

What am I doing wrong?

@dhruvmanila
Copy link
Member

You aren't doing anything wrong. Auto-fixes aren't available for all rules. As per the analysis output, the file only contains diagnostics which aren't fixable, so nothing happens.

You can refer to the rules documentation and check if a diagnostic code has a fix available or not. In your case there's only E501 for which ruff doesn't provide a fix.

@anentropic
Copy link
Author

ah, shame... "line too long" is the most common error and most useful one to have auto fixed

@dhruvmanila
Copy link
Member

Usually, a formatter like black would take care of splitting long lines but I guess, in your case, this might be a long string which it cannot reliably split and thus doesn't.

@anentropic
Copy link
Author

ah I see, so I should still use black as well... I had thought this would replace it

@evanrittenhouse
Copy link
Contributor

I believe we have plans to add a Ruff formatter, but it's a ways off. For now, black is still required.

@charliermarsh
Copy link
Member

That's right. For now, we don't autofix line wrapping, and we do recommend using Ruff alongside Black.

@charliermarsh charliermarsh closed this as not planned Won't fix, can't repro, duplicate, stale Apr 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants