You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
At the moment, inference fails if an empty dict is used (without
annotation) as one of the types. It's because the constraint solver
can't resolve `dict[str, int]` and `dict[Never, Never]`. However in this
case it's more reasonable to interpret the empty dict as `dict[Any,
Any]` and just using the first type instead. That matches the behavior
of pyright.
```py
T = TypeVar("T")
class A(Generic[T]): ...
def func1(a: A[T], b: T) -> T: ...
def a1(a: A[Dict[str, int]]) -> None:
reveal_type(func1(a, {}))
```
```
# before
main: error: Cannot infer type argument 1 of "func1" (diff)
main: note: Revealed type is "Any" (diff)
# after
main: note: Revealed type is "builtins.dict[builtins.str, builtins.int]"
```
0 commit comments