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

7 statements  

« prev     ^ index     » next       coverage.py v7.2.7, created at 2023-06-15 14:30 +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( 

19 cls: typing.Type[C], data: T_data, key: str = None, init: dict[str, typing.Any] = None, strict: bool = True 

20 ) -> C: 

21 """ 

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

23 

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

25 """ 

26 return load_into(cls, data, key=key, init=init, strict=strict)