From da8f50d368545a45baeac560fbad1c06b407b606 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Mon, 25 Sep 2023 16:35:52 +0100 Subject: [PATCH] Revert "Bump jsonschema to 4.19.* (#10583)" This reverts commit 6ca7505af71322818ff07c9d56c4376fd84450fb. --- stubs/jsonschema/METADATA.toml | 3 +- ...cy_keywords.pyi => _legacy_validators.pyi} | 0 stubs/jsonschema/jsonschema/_typing.pyi | 13 ----- stubs/jsonschema/jsonschema/_utils.pyi | 1 + .../{_keywords.pyi => _validators.pyi} | 0 stubs/jsonschema/jsonschema/validators.pyi | 51 +++++++------------ 6 files changed, 20 insertions(+), 48 deletions(-) rename stubs/jsonschema/jsonschema/{_legacy_keywords.pyi => _legacy_validators.pyi} (100%) delete mode 100644 stubs/jsonschema/jsonschema/_typing.pyi rename stubs/jsonschema/jsonschema/{_keywords.pyi => _validators.pyi} (100%) diff --git a/stubs/jsonschema/METADATA.toml b/stubs/jsonschema/METADATA.toml index f6c4a4dca2b5..8586b7fa003c 100644 --- a/stubs/jsonschema/METADATA.toml +++ b/stubs/jsonschema/METADATA.toml @@ -1,6 +1,5 @@ -version = "4.19.*" +version = "4.17.*" upstream_repository = "https://github.com/python-jsonschema/jsonschema" -requires = ["referencing"] partial_stub = true [tool.stubtest] diff --git a/stubs/jsonschema/jsonschema/_legacy_keywords.pyi b/stubs/jsonschema/jsonschema/_legacy_validators.pyi similarity index 100% rename from stubs/jsonschema/jsonschema/_legacy_keywords.pyi rename to stubs/jsonschema/jsonschema/_legacy_validators.pyi diff --git a/stubs/jsonschema/jsonschema/_typing.pyi b/stubs/jsonschema/jsonschema/_typing.pyi deleted file mode 100644 index bf096c3fa078..000000000000 --- a/stubs/jsonschema/jsonschema/_typing.pyi +++ /dev/null @@ -1,13 +0,0 @@ -from collections.abc import Callable, Iterable -from typing import Any, Protocol -from typing_extensions import TypeAlias - -from jsonschema.protocols import Validator -from referencing.jsonschema import Schema - -class SchemaKeywordValidator(Protocol): - def __call__(self, validator: Validator, value: Any, instance: Any, schema: Schema) -> None: ... - -id_of: TypeAlias = Callable[[Schema], str | None] # noqa: Y042 - -ApplicableValidators: TypeAlias = Callable[[Schema], Iterable[tuple[str, Any]]] diff --git a/stubs/jsonschema/jsonschema/_utils.pyi b/stubs/jsonschema/jsonschema/_utils.pyi index fd0207bd916e..e00eb7c25f88 100644 --- a/stubs/jsonschema/jsonschema/_utils.pyi +++ b/stubs/jsonschema/jsonschema/_utils.pyi @@ -13,6 +13,7 @@ class URIDict(MutableMapping[str, str]): class Unset: ... +def load_schema(name): ... def format_as_index(container: str, indices) -> str: ... def find_additional_properties( instance: Iterable[Incomplete], schema: Mapping[Incomplete, Incomplete] diff --git a/stubs/jsonschema/jsonschema/_keywords.pyi b/stubs/jsonschema/jsonschema/_validators.pyi similarity index 100% rename from stubs/jsonschema/jsonschema/_keywords.pyi rename to stubs/jsonschema/jsonschema/_validators.pyi diff --git a/stubs/jsonschema/jsonschema/validators.pyi b/stubs/jsonschema/jsonschema/validators.pyi index 72ef1f6cfcbe..47ace89da529 100644 --- a/stubs/jsonschema/jsonschema/validators.pyi +++ b/stubs/jsonschema/jsonschema/validators.pyi @@ -4,9 +4,6 @@ from contextlib import contextmanager from typing import Any, ClassVar from typing_extensions import TypeAlias -from referencing.jsonschema import Schema, SchemaRegistry -from referencing.typing import URI - from ._format import FormatChecker from ._types import TypeChecker from ._utils import Unset, URIDict @@ -17,6 +14,8 @@ _JsonObject: TypeAlias = Mapping[str, Any] _JsonValue: TypeAlias = _JsonObject | list[Any] | str | int | float | bool | None _ValidatorCallback: TypeAlias = Callable[[Any, Any, _JsonValue, _JsonObject], Iterator[ValidationError]] +_Schema: TypeAlias = Mapping[str, Any] + # This class does not exist at runtime. Compatible classes are created at # runtime by create(). class _Validator: @@ -25,45 +24,31 @@ class _Validator: TYPE_CHECKER: ClassVar[Incomplete] FORMAT_CHECKER: ClassVar[Incomplete] @staticmethod - def ID_OF(contents: Schema) -> URI | None: ... - schema: Schema - format_checker: FormatChecker | None - def __init__( - self, - schema: Schema, - resolver: Incomplete | None = None, - format_checker: FormatChecker | None = None, - *, - registry: SchemaRegistry = ..., - _resolver: Incomplete | None = None, - ) -> None: ... + def ID_OF(schema: _Schema) -> str: ... + schema: _Schema + resolver: Incomplete + format_checker: Incomplete + evolve: Incomplete + def __init__(self, schema: _Schema, resolver: Incomplete | None = ..., format_checker: Incomplete | None = ...) -> None: ... @classmethod - def check_schema(cls, schema: Schema, format_checker: FormatChecker | Unset = ...) -> None: ... - @property - def resolver(self): ... - def evolve(self, **changes) -> _Validator: ... - def iter_errors(self, instance, _schema: Schema | None = ...) -> Generator[Incomplete, None, None]: ... + def check_schema(cls, schema: _Schema, format_checker: FormatChecker | Unset = ...) -> None: ... + def iter_errors(self, instance, _schema: _Schema | None = ...) -> Generator[Incomplete, None, None]: ... def descend( - self, - instance, - schema: Schema, - path: Incomplete | None = ..., - schema_path: Incomplete | None = ..., - resolver: Incomplete | None = None, + self, instance, schema: _Schema, path: Incomplete | None = ..., schema_path: Incomplete | None = ... ) -> Generator[Incomplete, None, None]: ... def validate(self, *args, **kwargs) -> None: ... def is_type(self, instance, type): ... - def is_valid(self, instance, _schema: Schema | None = ...) -> bool: ... + def is_valid(self, instance, _schema: _Schema | None = ...) -> bool: ... def validates(version: str) -> Callable[..., Incomplete]: ... def create( - meta_schema: Schema, + meta_schema: _Schema, validators: Mapping[str, _ValidatorCallback] | tuple[()] = (), version: Incomplete | None = None, type_checker: TypeChecker = ..., format_checker: FormatChecker = ..., - id_of: Callable[[Schema], str] = ..., - applicable_validators: Callable[[Schema], Iterable[tuple[str, _ValidatorCallback]]] = ..., + id_of: Callable[[_Schema], str] = ..., + applicable_validators: Callable[[_Schema], Iterable[tuple[str, _ValidatorCallback]]] = ..., ) -> type[_Validator]: ... def extend( validator, @@ -99,7 +84,7 @@ class RefResolver: remote_cache: Incomplete | None = None, ) -> None: ... @classmethod - def from_schema(cls, schema: Schema, id_of=..., *args, **kwargs): ... + def from_schema(cls, schema: _Schema, id_of=..., *args, **kwargs): ... def push_scope(self, scope) -> None: ... def pop_scope(self) -> None: ... @property @@ -115,5 +100,5 @@ class RefResolver: def resolve_fragment(self, document, fragment): ... def resolve_remote(self, uri): ... -def validate(instance: object, schema: Schema, cls: type[_Validator] | None = None, *args: Any, **kwargs: Any) -> None: ... -def validator_for(schema: Schema | bool, default=...): ... +def validate(instance: object, schema: _Schema, cls: type[_Validator] | None = None, *args: Any, **kwargs: Any) -> None: ... +def validator_for(schema: _Schema | bool, default=...): ...