diff --git a/stubs/jsonschema/METADATA.toml b/stubs/jsonschema/METADATA.toml index a51d6edb1..2e800d80f 100644 --- a/stubs/jsonschema/METADATA.toml +++ b/stubs/jsonschema/METADATA.toml @@ -1 +1 @@ -version = "4.3.*" +version = "4.4.*" diff --git a/stubs/jsonschema/jsonschema/_utils.pyi b/stubs/jsonschema/jsonschema/_utils.pyi index 448be7e91..2b20d72a5 100644 --- a/stubs/jsonschema/jsonschema/_utils.pyi +++ b/stubs/jsonschema/jsonschema/_utils.pyi @@ -1,14 +1,15 @@ -from typing import Any, Generator, Iterable, Mapping, MutableMapping, Sized +from _typeshed import SupportsKeysAndGetItem +from typing import Any, Generator, Iterable, Iterator, Mapping, MutableMapping, Sized -class URIDict(MutableMapping[Any, Any]): +class URIDict(MutableMapping[str, str]): def normalize(self, uri: str) -> str: ... - store: dict[Any, Any] - def __init__(self, *args, **kwargs) -> None: ... - def __getitem__(self, uri): ... - def __setitem__(self, uri, value) -> None: ... - def __delitem__(self, uri) -> None: ... - def __iter__(self): ... - def __len__(self): ... + store: dict[str, str] + def __init__(self, __m: SupportsKeysAndGetItem[str, str] | Iterable[tuple[str, str]], **kwargs: str) -> None: ... + def __getitem__(self, uri: str) -> str: ... + def __setitem__(self, uri: str, value: str) -> None: ... + def __delitem__(self, uri: str) -> None: ... + def __iter__(self) -> Iterator[str]: ... + def __len__(self) -> int: ... class Unset: ... diff --git a/stubs/jsonschema/jsonschema/validators.pyi b/stubs/jsonschema/jsonschema/validators.pyi index 782902178..245e33118 100644 --- a/stubs/jsonschema/jsonschema/validators.pyi +++ b/stubs/jsonschema/jsonschema/validators.pyi @@ -1,28 +1,56 @@ -from typing import Any, Callable +from _typeshed import SupportsKeysAndGetItem +from collections.abc import Callable, Generator, Iterable +from typing import Any, ClassVar + +from ._utils import URIDict + +# This class does not exist at runtime. Compatible classes are created at +# runtime by create(). +class _Validator: + VALIDATORS: ClassVar[dict[Any, Any]] + META_SCHEMA: ClassVar[dict[Any, Any]] + TYPE_CHECKER: Any + @staticmethod + def ID_OF(): ... + schema: Any + resolver: Any + format_checker: Any + evolve: Any + @classmethod + def check_schema(cls, schema) -> None: ... + def iter_errors(self, instance, _schema: Any | None = ...) -> Generator[Any, None, None]: ... + def descend(self, instance, schema, path: Any | None = ..., schema_path: Any | None = ...) -> Generator[Any, None, None]: ... + def validate(self, *args, **kwargs) -> None: ... + def is_type(self, instance, type): ... + def is_valid(self, instance, _schema: Any | None = ...) -> bool: ... def validates(version: str) -> Callable[..., Any]: ... -def create(meta_schema, validators=..., version: Any | None = ..., type_checker=..., id_of=..., applicable_validators=...): ... +def create( + meta_schema, validators=..., version: Any | None = ..., type_checker=..., id_of=..., applicable_validators=... +) -> type[_Validator]: ... def extend(validator, validators=..., version: Any | None = ..., type_checker: Any | None = ...): ... -Draft3Validator: Any -Draft4Validator: Any -Draft6Validator: Any -Draft7Validator: Any -Draft201909Validator: Any -Draft202012Validator: Any +Draft3Validator: type[_Validator] +Draft4Validator: type[_Validator] +Draft6Validator: type[_Validator] +Draft7Validator: type[_Validator] +Draft201909Validator: type[_Validator] +Draft202012Validator: type[_Validator] + +_Handler = Callable[[str], Any] class RefResolver: - referrer: Any + referrer: str cache_remote: Any - handlers: Any - store: Any + handlers: dict[str, _Handler] + store: URIDict def __init__( self, - base_uri, - referrer, - store=..., + base_uri: str, + referrer: str, + store: SupportsKeysAndGetItem[str, str] | Iterable[tuple[str, str]] = ..., cache_remote: bool = ..., - handlers=..., + handlers: SupportsKeysAndGetItem[str, _Handler] | Iterable[tuple[str, _Handler]] = ..., urljoin_cache: Any | None = ..., remote_cache: Any | None = ..., ) -> None: ... @@ -41,5 +69,5 @@ class RefResolver: def resolve_fragment(self, document, fragment): ... def resolve_remote(self, uri): ... -def validate(instance, schema, cls: Any | None = ..., *args, **kwargs) -> None: ... +def validate(instance: object, schema: object, cls: type[_Validator] | None = ..., *args: Any, **kwargs: Any) -> None: ... def validator_for(schema, default=...): ...