Coverage for src/configuraptor/cls.py: 100%

7 statements  

« prev     ^ index     » next       coverage.py v7.2.7, created at 2023-06-14 11:42 +0200

1""" 

2Logic for the TypedConfig inheritable class. 

3""" 

4 

5import typing 

6 

7from .core import T_data, load_into 

8 

9C = typing.TypeVar("C", bound=typing.Any) 

10 

11 

12class TypedConfig: 

13 """ 

14 Can be used instead of load_into. 

15 """ 

16 

17 @classmethod 

18 def load(cls: typing.Type[C], data: T_data, key: str = None, init: dict[str, typing.Any] = None) -> C: 

19 """ 

20 Load a class' config values from the config file. 

21 

22 SomeClass.load(data, ...) = load_into(SomeClass, data, ...). 

23 """ 

24 return load_into(cls, data, key=key, init=init)