Coverage for src/configuraptor/loaders/loaders_shared.py: 100%

1"""

2 File loaders that work regardless of Python version.

3"""

4

5 import json as json_lib

6 from typing import BinaryIO

7

8 import yaml as yaml_lib

9

10 from ._types import T_config, as_tconfig

11

12

13 def json(f: BinaryIO) -> T_config:

14 """

15 Load a JSON file.

16 """

17 data = json_lib.load(f)

18 return as_tconfig(data)

19

20

21 def yaml(f: BinaryIO) -> T_config:

22 """

23 Load a YAML file.

24 """

25 data = yaml_lib.load(f, yaml_lib.SafeLoader)

26 return as_tconfig(data)