Skip to content

allowed-unused-imports doesn't work for top-level modules #19664

@zeevro

Description

@zeevro

Summary

$ ruff version
ruff 0.12.7

$ ruff check --isolated --config 'lint.pyflakes.allowed-unused-imports = ["os"]' <(echo 'import os')
/dev/fd/63:1:8: F401 [*] `os` imported but unused
  |
1 | import os
  |        ^^ F401
  |
  = help: Remove unused import: `os`

Found 1 error.
[*] 1 fixable with the `--fix` option.

$ ruff check --isolated --config 'lint.pyflakes.allowed-unused-imports = ["os"]' <(echo 'import os.path')
/dev/fd/63:1:8: F401 [*] `os.path` imported but unused
  |
1 | import os.path
  |        ^^^^^^^ F401
  |
  = help: Remove unused import: `os.path`

Found 1 error.
[*] 1 fixable with the `--fix` option.

$ ruff check --isolated --config 'lint.pyflakes.allowed-unused-imports = ["os.path"]' <(echo 'import os.path')
All checks passed!

Version

ruff 0.12.7

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedContributions especially welcome

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions