mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-23 20:31:32 +08:00
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:
@@ -1 +1 @@
|
||||
version = "4.2.*"
|
||||
version = "4.3.*"
|
||||
|
||||
@@ -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,
|
||||
|
||||
22
stubs/jsonschema/jsonschema/protocols.pyi
Normal file
22
stubs/jsonschema/jsonschema/protocols.pyi
Normal 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": ...
|
||||
Reference in New Issue
Block a user