diff --git a/stubs/jsonschema/METADATA.toml b/stubs/jsonschema/METADATA.toml index cb7498d03..a51d6edb1 100644 --- a/stubs/jsonschema/METADATA.toml +++ b/stubs/jsonschema/METADATA.toml @@ -1 +1 @@ -version = "4.2.*" +version = "4.3.*" diff --git a/stubs/jsonschema/jsonschema/__init__.pyi b/stubs/jsonschema/jsonschema/__init__.pyi index 96cfcb3cc..dcb925bc6 100644 --- a/stubs/jsonschema/jsonschema/__init__.pyi +++ b/stubs/jsonschema/jsonschema/__init__.pyi @@ -15,6 +15,7 @@ from jsonschema.exceptions import ( SchemaError as SchemaError, ValidationError as ValidationError, ) +from jsonschema.protocols import Validator as Validator from jsonschema.validators import ( Draft3Validator as Draft3Validator, Draft4Validator as Draft4Validator, diff --git a/stubs/jsonschema/jsonschema/protocols.pyi b/stubs/jsonschema/jsonschema/protocols.pyi new file mode 100644 index 000000000..451e4ec67 --- /dev/null +++ b/stubs/jsonschema/jsonschema/protocols.pyi @@ -0,0 +1,22 @@ +from typing import Any, ClassVar, Iterator, Protocol + +from jsonschema._format import FormatChecker +from jsonschema._types import TypeChecker +from jsonschema.exceptions import ValidationError +from jsonschema.validators import RefResolver + +class Validator(Protocol): + META_SCHEMA: ClassVar[dict[Any, Any]] + VALIDATORS: ClassVar[dict[Any, Any]] + TYPE_CHECKER: ClassVar[TypeChecker] + schema: dict[Any, Any] | bool + def __init__( + self, schema: dict[Any, Any] | bool, resolver: RefResolver | None = ..., format_checker: FormatChecker | None = ... + ) -> None: ... + @classmethod + def check_schema(cls, schema: dict[Any, Any]) -> None: ... + def is_type(self, instance: Any, type: str) -> bool: ... + def is_valid(self, instance: dict[Any, Any]) -> bool: ... + def iter_errors(self, instance: dict[Any, Any]) -> Iterator[ValidationError]: ... + def validate(self, instance: dict[Any, Any]) -> None: ... + def evolve(self, **kwargs) -> "Validator": ...