Skip to content
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

Support TypeAliasType #16926

Merged
merged 18 commits into from
Mar 11, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Add test requested in CR
  • Loading branch information
hamdanal committed Feb 20, 2024
commit c7b6357122c598bac7d2b34fd7c35477f384a4dc
8 changes: 4 additions & 4 deletions test-data/unit/check-type-aliases.test
Original file line number Diff line number Diff line change
Expand Up @@ -1105,6 +1105,7 @@ TestType = TypeAliasType("TestType", Dict[K, V], type_params=(K, V))
x: TestType[int, str] = {1: 'a'}
JelleZijlstra marked this conversation as resolved.
Show resolved Hide resolved
y: TestType[str, int] = {'a': 1}
z: TestType[str, int] = {1: 'a'} # E: Dict entry 0 has incompatible type "int": "str"; expected "str": "int"
w: TestType[int] # E: Bad number of arguments for type alias, expected 2, given 1

InvertedDict = TypeAliasType("InvertedDict", Dict[K, V], type_params=(V, K))
xi: InvertedDict[str, int] = {1: 'a'}
Expand Down Expand Up @@ -1169,11 +1170,10 @@ unbound_ps_alias: Ta7[[int], str] # E: Bracketed expression "[...]" is not vali
# E: Bad number of arguments for type alias, expected 0, given 2
reveal_type(unbound_ps_alias) # N: Revealed type is "__main__.G[Any, Any]"

# TODO this does not work yet, it should report unbound P
# TODO this does not work yet, it should report unbound P on the next line
# Ta8 = TypeAliasType("Ta8", Callable[P, int])
# unbound_ps_alias: Ta8[int]
# reveal_type(unbound_ps_alias)

# unbound_ps_alias2: Ta8[int]
# reveal_type(unbound_ps_alias2)

[builtins fixtures/dict.pyi]

Expand Down
Loading