diff options
Diffstat (limited to 'jsonschema/_types.py')
-rw-r--r-- | jsonschema/_types.py | 26 |
1 files changed, 11 insertions, 15 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): |