define a typeddict from a dataclass

135 views Asked by At

I am implementing a function that builds and returns a (frozen) dataclass. The dataclass definition is public and "official". Internally my implementation I need to do some complex logic to build the informations for the dataclass initialization, and I want to use a typeddict - that matches the fields in the dataclass - as a temporary holder.

I'm struggling to define the typeddict without just copying the fields... ideally I want to "dinamically" (but not really, as the dataclass fields are defined statically) define the typeddict fields

mypy-playground

0

There are 0 answers