Add jsonschema.protocols to library stubs (#6614)

`jsonschema.protocols.Validator` was introduced in `jsonschema` v4.3.0
It's also available under the name `jsonschema.Validator`.
This commit is contained in:
Stephen Rosen
2021-12-17 07:30:58 -05:00
committed by GitHub
parent df0a724c0f
commit 806a5bcece
3 changed files with 24 additions and 1 deletions

View File

@@ -1 +1 @@
version = "4.2.*"
version = "4.3.*"

View File

@@ -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,

View File

@@ -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": ...