aboutsummaryrefslogtreecommitdiff
path: root/src/hydrilla/json_instances.py
diff options
context:
space:
mode:
authorWojtek Kosior <koszko@koszko.org>2022-10-11 10:26:55 +0200
committerWojtek Kosior <koszko@koszko.org>2022-10-11 13:12:11 +0200
commit0c8d70daae4c4dfc989edad465db94ffc665416d (patch)
tree86f1b23e863b2dae1efd00686d46890b4b72ccb2 /src/hydrilla/json_instances.py
parent9074d98f711b6ccc099df8bccb1ed28390bcf0da (diff)
downloadhaketilo-hydrilla-0c8d70daae4c4dfc989edad465db94ffc665416d.tar.gz
haketilo-hydrilla-0c8d70daae4c4dfc989edad465db94ffc665416d.zip
[builder][server] restore compatibility with python 3.7
Diffstat (limited to 'src/hydrilla/json_instances.py')
-rw-r--r--src/hydrilla/json_instances.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/hydrilla/json_instances.py b/src/hydrilla/json_instances.py
index fb34d5c..e6cf50f 100644
--- a/src/hydrilla/json_instances.py
+++ b/src/hydrilla/json_instances.py
@@ -111,7 +111,7 @@ _schema_name_re = re.compile(r'''
$
''', re.VERBOSE)
-schema_paths: dict[str, Path] = {}
+schema_paths: t.Dict[str, Path] = {}
for path in (here / 'schemas').rglob('*.schema.json'):
match = _schema_name_re.match(path.name)
assert match is not None
@@ -126,12 +126,12 @@ for path in (here / 'schemas').rglob('*.schema.json'):
schema_paths.update([(f'https://hydrilla.koszko.org/schemas/{name}', path)
for name, path in schema_paths.items()])
-schemas: dict[Path, dict[str, t.Any]] = {}
+schemas: t.Dict[Path, t.Dict[str, t.Any]] = {}
class UnknownSchemaError(HaketiloException):
pass
-def _get_schema(schema_name: str) -> dict[str, t.Any]:
+def _get_schema(schema_name: str) -> t.Dict[str, t.Any]:
"""Return loaded JSON of the requested schema. Cache results."""
path = schema_paths.get(schema_name)
if path is None:
@@ -142,7 +142,7 @@ def _get_schema(schema_name: str) -> dict[str, t.Any]:
return schemas[path]
-def validator_for(schema: t.Union[str, dict[str, t.Any]]) -> Draft7Validator:
+def validator_for(schema: t.Union[str, t.Dict[str, t.Any]]) -> Draft7Validator:
"""
Prepare a validator for the provided schema.
@@ -163,7 +163,7 @@ def parse_instance(text: str) -> object:
"""Parse 'text' as JSON with additional '//' comments support."""
return json.loads(strip_json_comments(text))
-InstanceSource = t.Union[Path, str, io.TextIOBase, dict[str, t.Any], bytes]
+InstanceSource = t.Union[Path, str, io.TextIOBase, t.Dict[str, t.Any], bytes]
def read_instance(instance_or_path: InstanceSource) -> object:
"""...."""