union-annotation
What it does
Section titled “What it does”Reports a typing.Union[...] subscript when the target_version has X | Y (3.10 and later).
Why it matters
Section titled “Why it matters”Union[X, Y] is the same type as X | Y, which needs no import and reads like the other uses of |.
To fix, write X | Y.
Example
Section titled “Example”from typing import Unionx: Union[int, str]
from typing import Optional...Configuration
Section titled “Configuration”python: lint: rules: union-annotation: warn # off (default), warn, errorEnabled by the presets: python/ruff.
Suppress one line with sudsy-disable-next-line union-annotation 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 | UP007 |
full |