I am passing a Python dict with configuration parameters to my class. Since the config is loaded from a file (toml file in my case, but could be any file format), I cannot guarantee that all parameters are present in the file. Therefore, I am using a collections.defaultdict that provides default values for the parameters that are left out of the config (None is the default in my case). For more advanced static code check, I would like to use a typing.TypedDict for that config dict as well. It would also suit nicely as a documentation of which parameters are required and which ones are only optional. When I try to use the TypedDict by subclassing it, but also subclass the defaultdict with it, I get an exception TypedDict cannot inherit from a non-TypedDict base class. Here's a small example of it: from collections import defaultdict from typing import TypedDict class Config(TypedDict, defaultdict): identifier: int optional_param: str | None From what I understand, this limitation comes from PEP-589 and that TypedDict was later extended to support subclassing together with typing.Generics as well, but nothing more. I am using Python 3.11 but I don't see any changes for this part of Python source code even in the current Python version (3.13). My questions are: Is there some nice workaround to this limitation? Or should I just approach this in a completely different way? Since both collections.defaultdict and typing.TypedDict suit nicely for config dicts, would it be possible to have subclassing both of these together enabled in some future Python update? Or is there some blocker that is hard to resolve? Continue reading...