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

19 statements  

« prev     ^ index     » next       coverage.py v7.2.7, created at 2023-06-13 17:34 +0200

1""" 

2Main example. 

3 

4Should be removed soon. 

5""" 

6 

7from .core import load_into 

8 

9 

10class AbsHasName: 

11 name: str 

12 

13 

14# @dataclass 

15class 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 

24class Simple(AbsHasName): 

25 two: Two 

26 

27 def __repr__(self) -> str: 

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

29 

30 

31def 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 

39if __name__ == "__main__": 

40 main()