Coverage for src/configuraptor/loaders/loaders_shared.py: 100%
10 statements
« prev ^ index » next coverage.py v7.2.7, created at 2023-06-14 12:24 +0200
« prev ^ index » next coverage.py v7.2.7, created at 2023-06-14 12:24 +0200
1"""
2File loaders that work regardless of Python version.
3"""
5import json as json_lib
6from typing import BinaryIO
8import yaml as yaml_lib
10from ._types import T_config, as_tconfig
13def json(f: BinaryIO) -> T_config:
14 """
15 Load a JSON file.
16 """
17 data = json_lib.load(f)
18 return as_tconfig(data)
21def 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)