diff options
author | Julian Berman <Julian@GrayVines.com> | 2023-03-05 08:26:30 +0200 |
---|---|---|
committer | Julian Berman <Julian@GrayVines.com> | 2023-03-06 07:50:56 +0200 |
commit | eb004479645a4e1f0d842e4434b909f476569dcc (patch) | |
tree | dde7c42f3b86b949a3671bc15f6164a1e6ca1b8b | |
parent | 84199e984aba5f2c6bf5b121eb95faedc53951fc (diff) | |
download | jsonschema-eb004479645a4e1f0d842e4434b909f476569dcc.tar.gz |
Replace the other usages of pyrsistent with rpds.
-rw-r--r-- | jsonschema/_types.py | 26 | ||||
-rw-r--r-- | jsonschema/tests/test_cli.py | 6 | ||||
-rw-r--r-- | jsonschema/validators.py | 4 | ||||
-rw-r--r-- | pyproject.toml | 2 | ||||
-rw-r--r-- | tox.ini | 1 |
5 files changed, 16 insertions, 23 deletions
diff --git a/jsonschema/_types.py b/jsonschema/_types.py index 5b543f7..9f8dfa0 100644 --- a/jsonschema/_types.py +++ b/jsonschema/_types.py @@ -1,26 +1,22 @@ from __future__ import annotations +from typing import Any, Callable, Mapping import numbers -import typing -from pyrsistent import pmap -from pyrsistent.typing import PMap +from rpds import HashTrieMap import attr from jsonschema.exceptions import UndefinedTypeCheck -# unfortunately, the type of pmap is generic, and if used as the attr.ib +# unfortunately, the type of HashTrieMap is generic, and if used as the attr.ib # converter, the generic type is presented to mypy, which then fails to match # the concrete type of a type checker mapping # this "do nothing" wrapper presents the correct information to mypy -def _typed_pmap_converter( - init_val: typing.Mapping[ - str, - typing.Callable[["TypeChecker", typing.Any], bool], - ], -) -> PMap[str, typing.Callable[["TypeChecker", typing.Any], bool]]: - return pmap(init_val) +def _typed_map_converter( + init_val: Mapping[str, Callable[["TypeChecker", Any], bool]], +) -> HashTrieMap[str, Callable[["TypeChecker", Any], bool]]: + return HashTrieMap.convert(init_val) def is_array(checker, instance): @@ -82,11 +78,11 @@ class TypeChecker: The initial mapping of types to their checking functions. """ - _type_checkers: PMap[ - str, typing.Callable[["TypeChecker", typing.Any], bool], + _type_checkers: HashTrieMap[ + str, Callable[["TypeChecker", Any], bool], ] = attr.ib( - default=pmap(), - converter=_typed_pmap_converter, + default=HashTrieMap(), + converter=_typed_map_converter, ) def __repr__(self): diff --git a/jsonschema/tests/test_cli.py b/jsonschema/tests/test_cli.py index 6d5873a..c5b0b2e 100644 --- a/jsonschema/tests/test_cli.py +++ b/jsonschema/tests/test_cli.py @@ -16,8 +16,6 @@ try: # pragma: no cover except ImportError: # pragma: no cover import importlib_metadata as metadata # type: ignore -from pyrsistent import m - from jsonschema import Draft4Validator, Draft202012Validator from jsonschema.exceptions import ( SchemaError, @@ -70,13 +68,13 @@ def _message_for(non_json): class TestCLI(TestCase): def run_cli( - self, argv, files=m(), stdin=StringIO(), exit_code=0, **override, + self, argv, files=None, stdin=StringIO(), exit_code=0, **override, ): arguments = cli.parse_args(argv) arguments.update(override) self.assertFalse(hasattr(cli, "open")) - cli.open = fake_open(files) + cli.open = fake_open(files or {}) try: stdout, stderr = StringIO(), StringIO() actual_exit_code = cli.run( diff --git a/jsonschema/validators.py b/jsonschema/validators.py index bd13544..3182d13 100644 --- a/jsonschema/validators.py +++ b/jsonschema/validators.py @@ -16,8 +16,8 @@ import reprlib import warnings from jsonschema_specifications import REGISTRY as SPECIFICATIONS -from pyrsistent import m from referencing import Specification +from rpds import HashTrieMap import attr import referencing.jsonschema @@ -802,7 +802,7 @@ class _RefResolver: self, base_uri, referrer, - store=m(), + store=HashTrieMap(), cache_remote=True, handlers=(), urljoin_cache=None, diff --git a/pyproject.toml b/pyproject.toml index 19ba652..ad3152b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -32,9 +32,9 @@ dynamic = ["version", "readme"] dependencies = [ "attrs>=22.2.0", - "pyrsistent>=0.19.3", "jsonschema-specifications>=2023.03.1", "referencing>=0.21.0", + "rpds-py>=0.4.1", "importlib_metadata;python_version<'3.8'", "typing_extensions;python_version<'3.8'", @@ -92,7 +92,6 @@ deps = # FIXME: Why are we repeating dependencies here? attrs mypy - pyrsistent types-requests commands = {envpython} -m mypy --config {toxinidir}/pyproject.toml {posargs} {toxinidir}/jsonschema |