
I really want this feature for the scenario where you are getting data from some API/library that doesn’t fully describe the payload but you know one or two keys that you use. For example, boto3 returns a bunch of untyped dicts but I know that I want payload[“Key”] and that it is a string. I see that one of the major issues that were brought up was describing the type of the “extra” keys (even if that is Any). Could we do this by allowing classes to subclass both TypedDict and Dict? ``` from typing import Dict, TypedDict class Coefficients(Dict[str, float], TypedDict, allow_extra=True): x1: int x2: int f1: Coefficients = {"x1": 1, "x2": 2, "x3": 3.3} # ok f2: Coefficients = {"x1": "bad", "x2": 2, "x3": 3.3} # bad, x1 has wrong type f3: Coefficients = {"x1": 1, "x2": 2, "x3": "bad"} # bad, x3 has wrong type ``` I’m no type theorist but I think this transmits the idea that this is a dict with str keys and float values where some specific keys are narrowed to int (or it could be Dict[str, Any] with some keys of known types). I’m not sure what the right thing to do is w.r.t. mutability, but I suppose this could be restricted to be Mapping instead of Dict if we wanted to only allow this pattern for immutable objects?