Skip to content

Commit dc981ee

Browse files
authored
[jsonschema] Fix RefResolver store parameter type (#15542)
Change URIDict to use MutableMapping[str, Any] as the value type throughout, consistent with the actual runtime behavior where store values are schema documents (JSON objects), not plain strings.
1 parent 26380ee commit dc981ee

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

stubs/jsonschema/jsonschema/_utils.pyi

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
1-
from _typeshed import Incomplete, SupportsKeysAndGetItem, SupportsNext, SupportsRichComparison
1+
from _typeshed import Incomplete, SupportsNext, SupportsRichComparison
22
from collections.abc import Generator, Iterable, Iterator, Mapping, MutableMapping
3-
from typing import Literal, TypeVar, overload
3+
from typing import Any, Literal, TypeVar, overload
44

55
_T = TypeVar("_T")
66

7-
class URIDict(MutableMapping[str, str]):
7+
class URIDict(MutableMapping[str, MutableMapping[str, Any]]):
88
def normalize(self, uri: str) -> str: ...
9-
store: dict[str, str]
10-
def __init__(self, m: SupportsKeysAndGetItem[str, str] | Iterable[tuple[str, str]], /, **kwargs: str) -> None: ...
11-
def __getitem__(self, uri: str) -> str: ...
12-
def __setitem__(self, uri: str, value: str) -> None: ...
9+
store: dict[str, MutableMapping[str, Any]]
10+
def __init__(
11+
self,
12+
m: Mapping[str, MutableMapping[str, Any]] | Iterable[tuple[str, MutableMapping[str, Any]]],
13+
/,
14+
**kwargs: MutableMapping[str, Any],
15+
) -> None: ...
16+
def __getitem__(self, uri: str) -> MutableMapping[str, Any]: ...
17+
def __setitem__(self, uri: str, value: MutableMapping[str, Any]) -> None: ...
1318
def __delitem__(self, uri: str) -> None: ...
1419
def __iter__(self) -> Iterator[str]: ...
1520
def __len__(self) -> int: ...

stubs/jsonschema/jsonschema/validators.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ class RefResolver:
113113
self,
114114
base_uri: str,
115115
referrer: dict[str, Incomplete],
116-
store: SupportsKeysAndGetItem[str, str] | Iterable[tuple[str, str]] = ...,
116+
store: Mapping[str, Mapping[str, Any]] | Iterable[tuple[str, Mapping[str, Any]]] = ...,
117117
cache_remote: bool = True,
118118
handlers: SupportsKeysAndGetItem[str, _Handler] | Iterable[tuple[str, _Handler]] = (),
119119
urljoin_cache=None,

0 commit comments

Comments
 (0)