-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Open
Labels
configurationRelated to settings and configurationRelated to settings and configurationruleImplementing or modifying a lint ruleImplementing or modifying a lint rule
Description
Description
If an "unused" import is done with a relative path, allowed-unused-imports can't be configured to to allow it:
$ uv init --lib --name mod
$ cat >> pyproject.toml <<EOF
[tool.ruff]
lint.pyflakes.allowed-unused-imports = [
"mod.foo.bar",
]
EOF
$ echo "from .foo import bar" > src/mod/junk.py
$ echo "bar = None" > src/mod/foo.py
$ uvx ruff check src
src/mod/junk.py:1:18: F401 [*] `.foo.bar` imported but unused
|
1 | from .foo import bar
| ^^^ F401
|
= help: Remove unused import: `.foo.bar`
Found 1 error.
[*] 1 fixable with the `--fix` option.
$ uvx ruff version
ruff 0.9.3 (90589372d 2025-01-23)I was unable to find a spelling of mod.foo.bar that would work—none of .foo.bar, foo.bar, foo work.
If junk.py contains from mod.foo import bar (i.e., absolute path for the import), ruff allows the import as expected.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
configurationRelated to settings and configurationRelated to settings and configurationruleImplementing or modifying a lint ruleImplementing or modifying a lint rule