Improve annotation of jsonschema.validators.create (#8608)

This commit is contained in:
Stephen Rosen
2022-08-25 09:25:15 -04:00
committed by GitHub
parent c17c0d5607
commit 2c534dc220

View File

@@ -1,9 +1,17 @@
from _typeshed import SupportsKeysAndGetItem
from collections.abc import Callable, Generator, Iterable, Mapping
from collections.abc import Callable, Generator, Iterable, Iterator, Mapping
from typing import Any, ClassVar
from typing_extensions import TypeAlias
from ._format import FormatChecker
from ._types import TypeChecker
from ._utils import URIDict
from .exceptions import ValidationError
# these type aliases do not exist at runtime, they're only defined here in the stub
_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]
@@ -33,13 +41,13 @@ class _Validator:
def validates(version: str) -> Callable[..., Any]: ...
def create(
meta_schema,
validators=...,
meta_schema: _Schema,
validators: Mapping[str, _ValidatorCallback] | tuple[()] = ...,
version: Any | None = ...,
type_checker=...,
format_checker=...,
id_of=...,
applicable_validators=...,
type_checker: TypeChecker = ...,
format_checker: FormatChecker = ...,
id_of: Callable[[_Schema], str] = ...,
applicable_validators: Callable[[_Schema], Iterable[tuple[str, _ValidatorCallback]]] = ...,
) -> type[_Validator]: ...
def extend(
validator, validators=..., version: Any | None = ..., type_checker: Any | None = ..., format_checker: Any | None = ...