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
{{ message }}
Repository navigation
No matching overload found for function dict.__init__ when creating dict with different value types #562
When creating dictionaries with different type of values without manually specifying the type gives the error and the types are auto inferred based on the first value of the dict.
a=dict(key1="value1", key2=32)
This gives the error No matching overload found for function `dict.__init__` Possible overloads: () -> None (**kwargs: str) -> None [closest match] (map: SupportsKeysAndGetItem[str, str], /) -> None (map: SupportsKeysAndGetItem[str, str], /, **kwargs: str) -> None (iterable: Iterable[tuple[str, str]], /) -> None (iterable: Iterable[tuple[str, str]], /, **kwargs: str) -> None (iterable: Iterable[list[str]], /) -> None (iterable: Iterable[list[bytes]], /) -> NonePyrefly(no-matching-overload)
and the type inferred as dict[str, str]
If I use it with
a: dict[str, Any] =dict(key1="value1", key2=32)
This works fine
Don't know if this is intentional and this is how it is supposed to work in pyrefly?
Sandbox Link
No response
(Only applicable for extension issues) IDE Information
changed the title [-]No matching overload found for function `dict.__init__`[/-][+]No matching overload found for function `dict.__init__` when creating dict with different value types[/+]on Jun 24, 2025
Activity
[-]No matching overload found for function `dict.__init__`[/-][+]No matching overload found for function `dict.__init__` when creating dict with different value types[/+]yangdanny97 commentedon Jun 24, 2025
Thanks for reporting! Based on the error message, I think the root cause of this is #105