-
Notifications
You must be signed in to change notification settings - Fork 216
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.
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!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