|
1 | 1 | from __future__ import annotations |
2 | 2 |
|
| 3 | +from typing import Any, Callable, Mapping |
3 | 4 | import numbers |
4 | | -import typing |
5 | 5 |
|
6 | | -from pyrsistent import pmap |
7 | | -from pyrsistent.typing import PMap |
| 6 | +from rpds import HashTrieMap |
8 | 7 | import attr |
9 | 8 |
|
10 | 9 | from jsonschema.exceptions import UndefinedTypeCheck |
11 | 10 |
|
12 | 11 |
|
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 |
14 | 13 | # converter, the generic type is presented to mypy, which then fails to match |
15 | 14 | # the concrete type of a type checker mapping |
16 | 15 | # 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) |
24 | 20 |
|
25 | 21 |
|
26 | 22 | def is_array(checker, instance): |
@@ -82,11 +78,11 @@ class TypeChecker: |
82 | 78 | The initial mapping of types to their checking functions. |
83 | 79 | """ |
84 | 80 |
|
85 | | - _type_checkers: PMap[ |
86 | | - str, typing.Callable[["TypeChecker", typing.Any], bool], |
| 81 | + _type_checkers: HashTrieMap[ |
| 82 | + str, Callable[["TypeChecker", Any], bool], |
87 | 83 | ] = attr.ib( |
88 | | - default=pmap(), |
89 | | - converter=_typed_pmap_converter, |
| 84 | + default=HashTrieMap(), |
| 85 | + converter=_typed_map_converter, |
90 | 86 | ) |
91 | 87 |
|
92 | 88 | def __repr__(self): |
|
0 commit comments