unnecessary-type-union (PYI055)
Derived from the flake8-pyi linter.
Fix is sometimes available.
What it does
Checks for the presence of multiple type
s in a union.
Why is this bad?
type[T | S]
has identical semantics to type[T] | type[S]
in a type
annotation, but is cleaner and more concise.
Example
Use instead:
Fix safety
This rule's fix is marked as safe in most cases; however, the fix will flatten nested unions type expressions into a single top-level union.
The fix is marked as unsafe when comments are present within the type expression.