8000 Fix new style union syntax in type aliases by JukkaL · Pull Request #14008 · python/mypy · GitHub
[go: up one dir, main page]

Skip to content

Fix new style union syntax in type aliases #14008

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Nov 7, 2022
Prev Previous commit
Next Next commit
Test syntax in stubs with older Python version
  • Loading branch information
JukkaL committed Nov 7, 2022
commit 967a2cc2509c42bdf99b39af965cedc46ef183f5
27 changes: 27 additions & 0 deletions test-data/unit/pythoneval.test
Original file line number Diff line number Diff line change
Expand Up @@ -1683,3 +1683,30 @@ A = Type[int] | str
B: TypeAlias = Type[int] | str
[out]
_testTypeAliasWithNewStyleUnion.py:5: note: Revealed type is "typing._SpecialForm"

[case testTypeAliasWithNewStyleUnionInStub]
# flags: --python-version 3.7
import m

[file m.pyi]
from typing import Type
from typing_extensions import Literal, TypeAlias

Foo = Literal[1, 2]
reveal_type(Foo)
Bar1 = Foo | Literal[3]
Bar2 = Literal[3] | Foo

U1 = int | str
U2 = U1 | bytes
U3 = bytes | U1

Opt1 = None | int
Opt2 = None | float
Opt3 = int | None
Opt4 = float | None

A = Type[int] | str
B: TypeAlias = Type[int] | str
[out]
m.pyi:5: note: Revealed type is "typing._SpecialForm"
0