-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed a recent regression that resulted in unsolved type arguments wh…
…en a "bare" generic class (like `dict`) is passed as an argument to a function that accepts a `type[T]`. This addresses #5392.
- Loading branch information
1 parent
752b24a
commit 4d92540
Showing
3 changed files
with
37 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# This sample tests that the assignment of an instantiable generic class | ||
# without supplied type arguments is given default type arguments (typically | ||
# Unknown) when the TypeVar is solved. | ||
|
||
from typing import Any, TypeVar, reveal_type | ||
|
||
T = TypeVar("T") | ||
|
||
|
||
def deco1(t: type[T], val: Any) -> T: | ||
return val | ||
|
||
|
||
v1 = deco1(dict, {"foo": "bar"}) | ||
reveal_type(v1, expected_text="dict[Unknown, Unknown]") | ||
|
||
|
||
def deco2(t: T, val: Any) -> T: | ||
return val | ||
|
||
|
||
v2 = deco2(dict, {"foo": "bar"}) | ||
reveal_type(v2, expected_text="type[dict[Unknown, Unknown]]") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters