Closed max-muoto closed 2 weeks ago
all of the keys are known at code initialization time
That is not true; TypedDicts can contain arbitrary extra keys at runtime. PEP 728 will change this but has not yet been accepted.
all of the keys are known at code initialization time
That is not true; TypedDicts can contain arbitrary extra keys at runtime. PEP 728 will change this but has not yet been accepted.
I see, how can this occur today without PEP 728? Or are you saying it's likely for PEP 728 to be accepted, so there's no point in pre-empting this.
Any TypedDict with arbitrary other keys is a static subtype of another TypedDict, so the set of keys you can get from a TypedDict is not statically known.
I think you could make a good argument that
TypedDict.items()
should returndict_items[LiteralString, object]
, as all of the keys are known at code initialization time.