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(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)