deprecated-import
What it does
Section titled “What it does”Reports an import of a name from the wrong module for the target_version: a name of typing_extensions that typing, collections.abc or warnings has in that version, an alias in typing of a collections.abc class, or List, Dict, Set, FrozenSet, Tuple or Type.
Why it matters
Section titled “Why it matters”The backport module exists for old versions. Once the standard library has the name, importing it from there removes a dependency, and the old aliases of typing are deprecated in favour of the builtin generics and collections.abc.
To fix, import the name from the module that the message names.
Example
Section titled “Example”...from typing import Optional...
from typing import List...
from typing import Generator...
...import datetime...
from typing_extensions import Self
import sys...Configuration
Section titled “Configuration”python: lint: rules: deprecated-import: warn # off (default), warn, errorEnabled by the presets: python/ruff.
Suppress one line with sudsy-disable-next-line deprecated-import in a comment of the file’s language.
Upstream equivalents
Section titled “Upstream equivalents”The same check in other tools; Sudsy reports what each upstream rule reports.
| Tool | Rule | Match |
|---|---|---|
| ruff | UP035 |
full |