summaryrefslogtreecommitdiff
path: root/jsonschema
diff options
context:
space:
mode:
authorJulian Berman <Julian@GrayVines.com>2022-12-05 16:21:19 -0500
committerJulian Berman <Julian@GrayVines.com>2022-12-05 16:21:58 -0500
commit3c2b16941b3796388ef46ef43adf0a73a4bd5ce7 (patch)
tree8cbe71abfae96bf94f7b981297f2d312e4d88b8d /jsonschema
parent29fbba12934b77d707fe5a66d65ac60cb5cc1f27 (diff)
downloadjsonschema-3c2b16941b3796388ef46ef43adf0a73a4bd5ce7.tar.gz
Just pre-calculate the remotes in the suite loader.
Half of the things in functools don't exist in 3.7/3.8.
Diffstat (limited to 'jsonschema')
-rw-r--r--jsonschema/tests/_suite.py16
1 files changed, 7 insertions, 9 deletions
diff --git a/jsonschema/tests/_suite.py b/jsonschema/tests/_suite.py
index 7656771..c598e22 100644
--- a/jsonschema/tests/_suite.py
+++ b/jsonschema/tests/_suite.py
@@ -4,7 +4,7 @@ Python representations of the JSON Schema Test Suite tests.
from __future__ import annotations
from collections.abc import Iterable, Mapping
-from functools import cache, partial
+from functools import partial
from pathlib import Path
from typing import TYPE_CHECKING, Any
import json
@@ -47,15 +47,13 @@ def _find_suite():
class Suite:
_root: Path = field(factory=_find_suite)
+ _remotes: Mapping[str, Mapping[str, Any] | bool] = field(init=False)
- @property
- @cache # noqa: B019
- def _remotes(self) -> Mapping[str, Mapping[str, Any] | bool]:
+ def __attrs_post_init__(self):
jsonschema_suite = self._root.joinpath("bin", "jsonschema_suite")
- remotes = subprocess.check_output(
- [sys.executable, str(jsonschema_suite), "remotes"],
- )
- return json.loads(remotes.decode("utf-8"))
+ argv = [sys.executable, str(jsonschema_suite), "remotes"]
+ remotes = subprocess.check_output(argv).decode("utf-8")
+ object.__setattr__(self, "_remotes", json.loads(remotes))
def benchmark(self, runner: pyperf.Runner): # pragma: no cover
for name, Validator in _VALIDATORS.items():
@@ -68,7 +66,7 @@ class Suite:
return Version(
name=name,
path=self._root / "tests" / name,
- remotes=self._remotes, # type: ignore # python/mypy#5858
+ remotes=self._remotes,
)