-
Notifications
You must be signed in to change notification settings - Fork 140
Closed as duplicate of#544
Description
Summary
Check the following code:
from typing import TypeAlias
Foo: TypeAlias = "int | str"
Bar: TypeAlias = int | str
x: Foo = 0 # Fails
y: Bar = 0 # OKOutput of uvx ty check a.py --output-format concise (without any config files, in a fresh mktemp -d with the above snippet cat'd into a.py):
error[invalid-type-form] a.py:6:4: Variable of type `Literal["int | str"]` is not allowed in a type expression
Found 1 diagnostic
As per the spec, quotes should be ignored in the RHS, it is not a literal definition:)
This isn't a toy problem - quoted RHS is the most convenient way to define a recursive alias (at least prior to PEP695, but I'd personally use this on 3.12+ too) or make it dependent on TYPE_CHECKING-only imports.
Foo: TypeAlias = "int | Iterable[Foo]"Version
0.0.1-alpha.14
Metadata
Metadata
Assignees
Labels
No labels