Coverage for src/typedconfig/main.py: 0%

1"""

2 Main example.

3

4 Should be removed soon.

5"""

6

7 from .core import load_into

8

9

10 class AbsHasName:

11 name: str

12

13

14# @dataclass

15 class Two(AbsHasName):

16 some_str: str

17 some_int: int

18

19 def __repr__(self) -> str:

20 return f"{self.name=} {self.some_str=} {self.some_int=}"

21

22

23# @dataclass

24 class Simple(AbsHasName):

25 two: Two

26

27 def __repr__(self) -> str:

28 return f"{self.name=} {self.two=}"

29

30

31 def main() -> None:

32 data = {"simple": {"name": "Steve", "two": {"name": "Alex", "some_str": "string", "some_int": 30}}}

33

34 simple = load_into(Simple, data)

35 two = simple.two

36 print(simple, two)

37

38

39 if __name__ == "__main__":

40 main()