-
Notifications
You must be signed in to change notification settings - Fork 274
Open
Labels
diagnosticsRelated to reporting of diagnostics.Related to reporting of diagnostics.runtime semanticsAccurate modeling of how Python's semantics work at runtimeAccurate modeling of how Python's semantics work at runtime
Milestone
Description
Summary
Splitting this off from #437. Although UnionType was introduced in Python 3.10, it is possible to use the union syntax in function definitions (but not in type aliases or elsewhere) in Python 3.9 if you include from __future__ import annotations
mypy catches this; ty does not.
https://play.ty.dev/5c47f2d5-ef8c-4d2f-b227-f93178b29e57
def f(x: int|str) -> None: ...$ uvx --python 3.9 mypy --strict test.py
test.py:1: error: X | Y syntax for unions requires Python 3.10 [syntax]
Found 1 error in 1 file (checked 1 source file)
$ uvx ty check --python-version 3.9 test.py
All checks passed!https://play.ty.dev/23b020e7-4d07-49d7-9671-9918244dad1c
from __future__ import annotations
def f(x: int|str) -> None: ...$ uvx --python 3.9 mypy --strict test.py
Success: no issues found in 1 source file
$ uvx ty check --python-version 3.9 test.py
All checks passed!Version
ty 0.0.1-alpha.5 (4ad13f2 2025-05-17)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
diagnosticsRelated to reporting of diagnostics.Related to reporting of diagnostics.runtime semanticsAccurate modeling of how Python's semantics work at runtimeAccurate modeling of how Python's semantics work at runtime