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

1"""

2 Logic for the TypedConfig inheritable class.

3"""

4

5 import typing

6

7 from .core import T_data, load_into

8

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

10

11

12 class 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)