Closed AA-Turner closed 1 month ago
Thanks, this makes sense. Will fix.
It's kind of an obvious failure, whoops -- but it's never come up because "required imports" is typically used for from __future
imports, which are never marked as unused.
As background, this came up in the context of moving Sphinx to pathlib
globally (or at least attempting to). I wanted to add from pathlib import Path
to every module to avoid undefined name errors when doing simple regex-based refactorings, but when I ran ruff check . --fix
I had this error.
I'm not sure which of the required import or the undefined name should take priority (instict says the required import, as the user has requested it), but hopefully Ruff shouldn't crash!
Thank you for the quick response as always Charlie!
Best, Adam
Totally. That's a clever trick! (I'm guessing you can workaround by running I002
first with the required-import
, then F401
second, without the required-import
?)
Agree that the required import should take priority. Think we just need to respect that in F401
.
I'm guessing you can workaround by running
I002
first with therequired-import
, thenF401
second, without therequired-import
?
Yep, running with --select
fixed things -- I just wanted to report upstream to make the team aware!
A
Thanks Charlie!
A
I ran into a fun error:
The content of
bug.py
is"_ = 'Path'\n"
. If you remove the assignment, all works (one imagines as the string is parsed as a docstring).The error exists going back at least as far as 0.2.2 (0.2.1 gives errors with mixing
--isolated
and--config
).I can't see any similar issues, but if I've missed one please close this!
A