-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed as duplicate of#4656
Description
Summary
Hi,
I'm occasionally struggling with the F401 rule, I managed to reproduce the issue with the following example.
Given this file, named ruff_F401.py:
def my_method():
import package.a.b.c.d.module_a
import package.a.b.c.d.module_b
import package.a.b.e.module_cWhen I run ruff --isolated check ruff_F401.py I get the following report:
ruff_F401.py:4:12: F401 [*] `package.a.b.e.module_c` imported but unused
|
2 | import package.a.b.c.d.module_a
3 | import package.a.b.c.d.module_b
4 | import package.a.b.e.module_c
| ^^^^^^^^^^^^^^^^^^^^^^ F401
|
= help: Remove unused import: `package.a.b.e.module_c`
Found 1 error.
[*] 1 fixable with the `--fix` option.If I provide the --fix argument, then the 3 imports are replaced with a pass.
Expected behaviour:
I'd expect a F401 error to be reported for each of the 3 lines.
Version
ruff 0.11.4 (95d6ed4 2025-04-04)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels