mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-09 05:24:52 +08:00
Treat validators as classes (#7035)
Co-authored-by: Akuli <akuviljanen17@gmail.com>
This commit is contained in:
@@ -4,6 +4,8 @@ from typing import Any, ClassVar
|
||||
|
||||
from ._utils import URIDict
|
||||
|
||||
_Schema = Any
|
||||
|
||||
# This class does not exist at runtime. Compatible classes are created at
|
||||
# runtime by create().
|
||||
class _Validator:
|
||||
@@ -11,11 +13,12 @@ class _Validator:
|
||||
META_SCHEMA: ClassVar[dict[Any, Any]]
|
||||
TYPE_CHECKER: Any
|
||||
@staticmethod
|
||||
def ID_OF(): ...
|
||||
def ID_OF(schema: _Schema) -> str: ...
|
||||
schema: Any
|
||||
resolver: Any
|
||||
format_checker: Any
|
||||
evolve: Any
|
||||
def __init__(self, schema: _Schema, resolver: Any | None = ..., format_checker: Any | None = ...) -> None: ...
|
||||
@classmethod
|
||||
def check_schema(cls, schema) -> None: ...
|
||||
def iter_errors(self, instance, _schema: Any | None = ...) -> Generator[Any, None, None]: ...
|
||||
@@ -30,12 +33,13 @@ def create(
|
||||
) -> type[_Validator]: ...
|
||||
def extend(validator, validators=..., version: Any | None = ..., type_checker: Any | None = ...): ...
|
||||
|
||||
Draft3Validator: type[_Validator]
|
||||
Draft4Validator: type[_Validator]
|
||||
Draft6Validator: type[_Validator]
|
||||
Draft7Validator: type[_Validator]
|
||||
Draft201909Validator: type[_Validator]
|
||||
Draft202012Validator: type[_Validator]
|
||||
# At runtime these are fields that are assigned the return values of create() calls.
|
||||
class Draft3Validator(_Validator): ...
|
||||
class Draft4Validator(_Validator): ...
|
||||
class Draft6Validator(_Validator): ...
|
||||
class Draft7Validator(_Validator): ...
|
||||
class Draft201909Validator(_Validator): ...
|
||||
class Draft202012Validator(_Validator): ...
|
||||
|
||||
_Handler = Callable[[str], Any]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user