I'm trying to use code like this to create a TypedDict which is a superset of another TypedDict:
from typing import TypedDict
class Base(TypedDict):
a: str
class Extend(Base):
b: str
base_instance: Base = {"a": "string!"}
extend_instance: Extend = {**base_instance, "b": "another string"}
But this emits a diagnostic warning about extend_instance: "Expression of type "dict[str, object | str]" cannot be assigned to declared type "Extend""
It's not clear to me why the values in extend_instance are assumed to be object | str, rather than just str.
Is there something I can do to annotate this better?
Thanks in advance.