Skip to content

F401 unused import false negative #4656

@sbrugman

Description

@sbrugman

False negative

import importlib # this package is unused, but not detected
import importlib.util 

package = "ruff"
is_present = importlib.util.find_spec(package)

When from importlib import util is used, correct behaviour is observed

import importlib # this package is unused, and detected
from importlib import util 

package = "ruff"
is_present = util.find_spec(package)

Ruff 'v0.0.270'

(hope I'm overlooking some submodule complexity in the general case, but it seems that in this specific case import importlib can be safely removed)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingneeds-decisionAwaiting a decision from a maintainer

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions