How to convert TypedDict definition to dataclass definition

Viewed 22

I would like to convert automatically TypedDict definition into Dataclasses definition

For example, this code contains duplication of code:

from typing_extensions import TypedDict
from dataclasses import dataclass

class Square(TypedDict):
  l : float

@dataclass
class DataClassSquare:
  l : float

I would like to do something like that:

from typing_extensions import TypedDict
from dataclasses import dataclass

class Square(TypedDict):
  l : float

DataClassSquare = converter(Square)

But I do not know how to write the converter.

Any idea?

0 Answers
Related