File: _json.py

package info (click to toggle)
python-cyclopts 3.12.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,288 kB
  • sloc: python: 11,445; makefile: 24
file content (16 lines) | stat: -rw-r--r-- 428 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
from pathlib import Path
from typing import Any

from cyclopts.config._common import ConfigFromFile
from cyclopts.exceptions import CoercionError


class Json(ConfigFromFile):
    def _load_config(self, path: Path) -> dict[str, Any]:
        import json

        with path.open() as f:
            try:
                return json.load(f)
            except json.JSONDecodeError as e:
                raise CoercionError from e