Bug Report
A generic TypeDict's update() doesn't allow calls with another similar dict, even though a non-generic version works fine. In my actual use-case I'm using constrained typevars, but the same issue occurs with unconstrained ones.
To Reproduce
from typing import TypedDict, reveal_type
class Group[ValT](TypedDict):
a: ValT
value: Group[int] = {"a": 1}
def func(value2: Group[int]) -> None:
reveal_type(value) # TypedDict('__main__.Group', {'a': builtins.int})
reveal_type(value.update) # def (TypedDict('__main__.Group', {'a': builtins.int}))
reveal_type(value2) # TypedDict('__main__.Group', {'a': builtins.int})
# error: Argument 1 to "update" of "TypedDict" has incompatible type "Group[int]"; expected "TypedDict({'a': ValT})" [typeddict-item]
value.update(value2)
https://mypy-play.net/?mypy=master&python=3.12&gist=2a40a79bdb543d8b28669f40bdc1c876
Expected Behavior
The update() call is accepted without error, the same as the non-generic version.
Actual Behavior
update() doesn't seem to have solved typevars, though reveal_type shows the correct function definition.
Your Environment
- Mypy version used: 1.19.1, also tried master (
1.20.0+dev.c5c12fad9e69525fa5b12058b328d284c5feecc4)
- Mypy command-line flags: Playground defaults
- Mypy configuration options from
mypy.ini (and other config files): Playground defaults
- Python version used: 3.12, 3.14
Bug Report
A generic TypeDict's
update()doesn't allow calls with another similar dict, even though a non-generic version works fine. In my actual use-case I'm using constrained typevars, but the same issue occurs with unconstrained ones.To Reproduce
https://mypy-play.net/?mypy=master&python=3.12&gist=2a40a79bdb543d8b28669f40bdc1c876
Expected Behavior
The
update()call is accepted without error, the same as the non-generic version.Actual Behavior
update()doesn't seem to have solved typevars, thoughreveal_typeshows the correct function definition.Your Environment
1.20.0+dev.c5c12fad9e69525fa5b12058b328d284c5feecc4)mypy.ini(and other config files): Playground defaults