Skip to content

Commit 3c2b169

Browse files
committed
Just pre-calculate the remotes in the suite loader.
Half of the things in functools don't exist in 3.7/3.8.
1 parent 29fbba1 commit 3c2b169

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

jsonschema/tests/_suite.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from __future__ import annotations
55

66
from collections.abc import Iterable, Mapping
7-
from functools import cache, partial
7+
from functools import partial
88
from pathlib import Path
99
from typing import TYPE_CHECKING, Any
1010
import json
@@ -47,15 +47,13 @@ def _find_suite():
4747
class Suite:
4848

4949
_root: Path = field(factory=_find_suite)
50+
_remotes: Mapping[str, Mapping[str, Any] | bool] = field(init=False)
5051

51-
@property
52-
@cache # noqa: B019
53-
def _remotes(self) -> Mapping[str, Mapping[str, Any] | bool]:
52+
def __attrs_post_init__(self):
5453
jsonschema_suite = self._root.joinpath("bin", "jsonschema_suite")
55-
remotes = subprocess.check_output(
56-
[sys.executable, str(jsonschema_suite), "remotes"],
57-
)
58-
return json.loads(remotes.decode("utf-8"))
54+
argv = [sys.executable, str(jsonschema_suite), "remotes"]
55+
remotes = subprocess.check_output(argv).decode("utf-8")
56+
object.__setattr__(self, "_remotes", json.loads(remotes))
5957

6058
def benchmark(self, runner: pyperf.Runner): # pragma: no cover
6159
for name, Validator in _VALIDATORS.items():
@@ -68,7 +66,7 @@ def version(self, name) -> Version:
6866
return Version(
6967
name=name,
7068
path=self._root / "tests" / name,
71-
remotes=self._remotes, # type: ignore # python/mypy#5858
69+
remotes=self._remotes,
7270
)
7371

7472

0 commit comments

Comments
 (0)