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

Sometimes --fix doesn't work (unused imports) #475

Closed
fsouza opened this issue Oct 26, 2022 · 2 comments · Fixed by #479
Closed

Sometimes --fix doesn't work (unused imports) #475

fsouza opened this issue Oct 26, 2022 · 2 comments · Fixed by #479
Assignees

Comments

@fsouza
Copy link
Contributor

fsouza commented Oct 26, 2022

I haven't been able to dig into this yet, but sometimes --fix doesn't remove unused imports (but it does claim to have fixed the issue). Reproducing with the autoflake repo:

$ git clone https://github.com/pycqa/autoflake.git /tmp/autoflake
$ cd /tmp/autoflake
$ patch -p1 <<EOF
\ diff --git a/autoflake.py b/autoflake.py
index 2b7b917..12a9f4f 100755
--- a/autoflake.py
+++ b/autoflake.py
@@ -38,6 +38,7 @@ import tokenize
 import pyflakes.api
 import pyflakes.messages
 import pyflakes.reporter
+from pyflakes.checker import Annotation


 __version__ = "1.7.7"
EOF
$ ruff autoflake.py
Found 1 error(s).
autoflake.py:41:1: F401 `pyflakes.checker.Annotation` imported but unused
1 potentially fixable with the --fix option.
% ruff --fix autoflake.py
Found 0 error(s) (1 fixed).
% ruff autoflake.py
Found 1 error(s).
autoflake.py:41:1: F401 `pyflakes.checker.Annotation` imported but unused
1 potentially fixable with the --fix option.

Note how it claims to have fixed the error ("Found 0 error(s) (1 fixed)."), but it didn't.

I can dig into it before the end of the week, but reporting just in case someone beats me to it :)

@charliermarsh
Copy link
Member

Awesome, thanks for reporting!

@charliermarsh charliermarsh self-assigned this Oct 26, 2022
@charliermarsh
Copy link
Member

Reproduced, I see the issue.

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

Successfully merging a pull request may close this issue.

2 participants