-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
F401 false positive (imported but unused) #2044
Comments
a simpler example without external dependencies
Regarding this specific issue:
It does make sense to only output F811 in this case (ignoring if the conditional is |
Yeah -- this was an intentional deviation from Flake8, since it avoids a lot of false negatives, but perhaps the tradeoff here is wrong given that autofixing false positives is more dangerous. |
I'll likely change this today, to avoid these issues. |
Just to prove that this behavior isn't totally without merit, Ruff will flag this as unused (and remove it), unlike Flake8: import os
def os():
pass But, I agree that it's probably wrong to do that right now given the false positives. |
just for completeness - |
👍 That makes sense. Pylint does more static analysis than we do right. |
The relevant PR that introduced this behavior is: #1173. |
I came here with a problem in this file: https://github.com/MichaelTiemannOSC/pint-pandas/blob/ducks-unlimited/pint_pandas/testsuite/test_pandas_extensiontests.py The problem is line 24. |
Except that ruff cannot be made happy, see astral-sh/ruff#2044 Signed-off-by: Michael Tiemann <72577720+MichaelTiemannOSC@users.noreply.github.com>
Yes, #4046 especially. Note: I'm not a maintainer of the project I'm contributing to, nor do I control the CI/CD. I'm just caught in the crossfire between how the developers factored the pytest code, what ruff thinks is OK or not, and when, if ever, the CI/CD will tell the maintainers they should bother looking at my code. I'm surprised that I cannot manually override this somehow. |
I think the error you're seeing is on line 498, not line 24:
Flake8 gives the same result. You should be able to add a |
Silly me! I didn't put the F811 where it belonged. Now fixed... Thanks! |
It is supposed to work like this:
Here is what ruff outputs:
If we apply the fix, then the code no longer works if the user presses "N" to not disable reduce.
The text was updated successfully, but these errors were encountered: