Skip to content

Add tests for PEP 593 annotated generic aliases #7985

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 2 commits into from
Nov 20, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions test-data/unit/check-annotated.test
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,39 @@ reveal_type(x) # N: Revealed type is 'Any'
[case testAnnotatedNoImport]
x: Annotated[int, ...] # E: Name 'Annotated' is not defined
reveal_type(x) # N: Revealed type is 'Any'

[case testAnnotatedDifferentName]
from typing_extensions import Annotated as An
x: An[int, ...]
reveal_type(x) # N: Revealed type is 'builtins.int'

[case testAnnotatedAliasSimple]
from typing import Tuple
from typing_extensions import Annotated
Alias = Annotated[Tuple[int, ...], ...]
x: Alias
reveal_type(x) # N: Revealed type is 'builtins.tuple[builtins.int]'

[case testAnnotatedAliasTypeVar]
from typing import TypeVar
from typing_extensions import Annotated
T = TypeVar('T')
Alias = Annotated[T, ...]
x: Alias[int]
reveal_type(x) # N: Revealed type is 'builtins.int'

[case testAnnotatedAliasGenericTuple]
from typing import TypeVar, Tuple
from typing_extensions import Annotated
T = TypeVar('T')
Alias = Annotated[Tuple[T, T], ...]
x: Alias[int]
reveal_type(x) # N: Revealed type is 'Tuple[builtins.int, builtins.int]'

[case testAnnotatedAliasGenericUnion]
from typing import TypeVar, Union
from typing_extensions import Annotated
T = TypeVar('T')
Alias = Annotated[Union[T, str], ...]
x: Alias[int]
reveal_type(x) # N: Revealed type is 'Union[builtins.int, builtins.str]'
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy