ref: python-jsonschema/jsonschema#997
I expected the following code to work when it comes to typing
from typing import Any, Mapping
import jsonschema
store: dict[str, Mapping[str, Any]] = {}
jsonschema.RefResolver(
base_uri=f"file://mypath.json",
referrer={},
store=store
)
However, this gives an error:
test.py:9: error: Argument "store" to "RefResolver" has incompatible type "Dict[str, Mapping[str, Any]]"; expected "Union[SupportsKeysAndGetItem[str, str], Iterable[Tuple[str, str]]]" [arg-type]
Found 1 error in 1 file (checked 1 source file)
defined at
|
class RefResolver: |
|
referrer: dict[str, Any] |
|
cache_remote: Any |
|
handlers: dict[str, _Handler] |
|
store: URIDict |
|
def __init__( |
|
self, |
|
base_uri: str, |
|
referrer: dict[str, Any], |
|
store: SupportsKeysAndGetItem[str, str] | Iterable[tuple[str, str]] = ..., |
|
cache_remote: bool = ..., |
|
handlers: SupportsKeysAndGetItem[str, _Handler] | Iterable[tuple[str, _Handler]] = ..., |
|
urljoin_cache: Any | None = ..., |
|
remote_cache: Any | None = ..., |
|
) -> None: ... |
. It seems incorrect that
store is a
dict[str, str] type.
Similarly, referrer is defined as a dict (MutableMapping) but I suspect that could be changed to Mapping (generically).
ref: python-jsonschema/jsonschema#997
I expected the following code to work when it comes to typing
However, this gives an error:
defined at
typeshed/stubs/jsonschema/jsonschema/validators.pyi
Lines 66 to 80 in c1d307f
storeis adict[str, str]type.Similarly,
referreris defined as adict(MutableMapping) but I suspect that could be changed toMapping(generically).