Introduce Partial for TypedDict

total only applies to keys that were added in the subclass, it doesn’t apply to keys from parent classes. We can’t really change that at this point, since it would break existing code:

Currently it’s also disallowed to override keys that have already been specified by parent classes to prevent confusion[1]. PEP 705 alleviates some of that with ReadOnly keys which can be more freely overridden in subclasses, but it would still disallow this use-case, going the other way is fine though[2].


  1. even though structural types don’t really care about inheritance, it would still be confusing if the subclass wasn’t structurally a subtype of the parent ↩︎

  2. i.e. start with fully optional and end up with partially or fully required ↩︎

1 Like