TypedDict types cannot be inferred through generic function calls where other parameter provides type restriction
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 516
- PR merge metrics
- No merged PRs in 30d
Description
### Describe the Bug
```py
from typing import *
Movie = TypedDict('Movie', {'name': str, 'year': int})
def rate_movie(movie: Movie) -> None:
pass
T = TypeVar("T", bound=Any)
def apply_operation(operation: Callable[[T], None], param: T) -> None:
pass
rate_movie({'name': 'Blade Runner', 'year': 1982})
apply_operation(rate_movie, {'name': 'Blade Runner', 'year': 1982})
```
In this example code (can also be found in the sandbox link), the direct invocation of `rate_movie` doesn't produce any error but trying to provide the exact same parameter through `apply_operation` produces the error:
ERROR sandbox.py:16:29-67: Argument `dict[str, int | str]` is not assignable to parameter `param` with type `Movie` in function `apply_operation` [[bad-argument-type](https://pyrefly.org/en/docs/error-kinds/#bad-argument-type)]
### Sandbox Link
https://pyrefly.org/sandbox/?project=N4IgZglgNgpgziAXKOBDAdgEwEYHsAeAdAA4CeS4ATrgLYAEALqcROgOZ0Q3G6UN0AqADroRAWVwA3CDDoBeOgBVmMTABEIAYwYAKAOQTpMPQBo6wPelQ1jiOnAaUze0jFSU9d1gwC%2BAShFArBgwOkpUBhgAfRopGR1YoztDGT86AFoAPjoAOVx0GEQROhK6YlQ4OCDFeSUVADV3HSEQRRazPABXLDkAQXRSANFhzBC6VGJiKFIo3GIYcIYIfJ05hYjl9DsAYVQoKFRsWABtY8UAXTM8gsuy92s7RTSs3PzC4tLyyqDF6MT4ixWGyeOh6ABCB1GdAASt0Ch5nK53CCAIwATgAHAAmfwiCZTGZrRabHS-GJxGBmQHWWygiGoKGw9Dw0ygpEeOzo7G49AgEwgMiUELTQgMWhQCgAYjoAAVSEKwNN7BgcAQ6Jp8pA2J1iflCCJpQBlGCyAAWDAYxDgiAA9DbBcLSIReGwbTB0DbMLhNHAbRr0FqdRt8ja6GBeONJKhoIdYOrNRBtbr0HQ5kt8nB9egyAxTfl0pIFnBNrUWgBmQgorEtETHBbUShwc4ibpcHh8VTpTAQIXaCCF2p6RPoXjGEQjhjpIUAR06Pc7AGsYKR0qhNJp4HBBwB3dzoPQiEA%2BflrpaFgBi0BgFDQWDwRDIR6AA
### (Only applicable for extension issues) IDE Information
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.