Skip to content

Commit eb00447

Browse files
committed
Replace the other usages of pyrsistent with rpds.
1 parent 84199e9 commit eb00447

File tree

5 files changed

+16
-23
lines changed

5 files changed

+16
-23
lines changed

jsonschema/_types.py

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,22 @@
11
from __future__ import annotations
22

3+
from typing import Any, Callable, Mapping
34
import numbers
4-
import typing
55

6-
from pyrsistent import pmap
7-
from pyrsistent.typing import PMap
6+
from rpds import HashTrieMap
87
import attr
98

109
from jsonschema.exceptions import UndefinedTypeCheck
1110

1211

13-
# unfortunately, the type of pmap is generic, and if used as the attr.ib
12+
# unfortunately, the type of HashTrieMap is generic, and if used as the attr.ib
1413
# converter, the generic type is presented to mypy, which then fails to match
1514
# the concrete type of a type checker mapping
1615
# this "do nothing" wrapper presents the correct information to mypy
17-
def _typed_pmap_converter(
18-
init_val: typing.Mapping[
19-
str,
20-
typing.Callable[["TypeChecker", typing.Any], bool],
21-
],
22-
) -> PMap[str, typing.Callable[["TypeChecker", typing.Any], bool]]:
23-
return pmap(init_val)
16+
def _typed_map_converter(
17+
init_val: Mapping[str, Callable[["TypeChecker", Any], bool]],
18+
) -> HashTrieMap[str, Callable[["TypeChecker", Any], bool]]:
19+
return HashTrieMap.convert(init_val)
2420

2521

2622
def is_array(checker, instance):
@@ -82,11 +78,11 @@ class TypeChecker:
8278
The initial mapping of types to their checking functions.
8379
"""
8480

85-
_type_checkers: PMap[
86-
str, typing.Callable[["TypeChecker", typing.Any], bool],
81+
_type_checkers: HashTrieMap[
82+
str, Callable[["TypeChecker", Any], bool],
8783
] = attr.ib(
88-
default=pmap(),
89-
converter=_typed_pmap_converter,
84+
default=HashTrieMap(),
85+
converter=_typed_map_converter,
9086
)
9187

9288
def __repr__(self):

jsonschema/tests/test_cli.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
except ImportError: # pragma: no cover
1717
import importlib_metadata as metadata # type: ignore
1818

19-
from pyrsistent import m
20-
2119
from jsonschema import Draft4Validator, Draft202012Validator
2220
from jsonschema.exceptions import (
2321
SchemaError,
@@ -70,13 +68,13 @@ def _message_for(non_json):
7068

7169
class TestCLI(TestCase):
7270
def run_cli(
73-
self, argv, files=m(), stdin=StringIO(), exit_code=0, **override,
71+
self, argv, files=None, stdin=StringIO(), exit_code=0, **override,
7472
):
7573
arguments = cli.parse_args(argv)
7674
arguments.update(override)
7775

7876
self.assertFalse(hasattr(cli, "open"))
79-
cli.open = fake_open(files)
77+
cli.open = fake_open(files or {})
8078
try:
8179
stdout, stderr = StringIO(), StringIO()
8280
actual_exit_code = cli.run(

jsonschema/validators.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
import warnings
1717

1818
from jsonschema_specifications import REGISTRY as SPECIFICATIONS
19-
from pyrsistent import m
2019
from referencing import Specification
20+
from rpds import HashTrieMap
2121
import attr
2222
import referencing.jsonschema
2323

@@ -802,7 +802,7 @@ def __init__(
802802
self,
803803
base_uri,
804804
referrer,
805-
store=m(),
805+
store=HashTrieMap(),
806806
cache_remote=True,
807807
handlers=(),
808808
urljoin_cache=None,

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ dynamic = ["version", "readme"]
3232

3333
dependencies = [
3434
"attrs>=22.2.0",
35-
"pyrsistent>=0.19.3",
3635
"jsonschema-specifications>=2023.03.1",
3736
"referencing>=0.21.0",
37+
"rpds-py>=0.4.1",
3838

3939
"importlib_metadata;python_version<'3.8'",
4040
"typing_extensions;python_version<'3.8'",

tox.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ deps =
9292
# FIXME: Why are we repeating dependencies here?
9393
attrs
9494
mypy
95-
pyrsistent
9695
types-requests
9796
commands = {envpython} -m mypy --config {toxinidir}/pyproject.toml {posargs} {toxinidir}/jsonschema
9897

0 commit comments

Comments
 (0)