|
1 | 1 | from _typeshed import SupportsKeysAndGetItem |
2 | | -from collections.abc import Callable, Generator, Iterable, Mapping |
| 2 | +from collections.abc import Callable, Generator, Iterable, Iterator, Mapping |
3 | 3 | from typing import Any, ClassVar |
4 | 4 | from typing_extensions import TypeAlias |
5 | 5 |
|
| 6 | +from ._format import FormatChecker |
| 7 | +from ._types import TypeChecker |
6 | 8 | from ._utils import URIDict |
| 9 | +from .exceptions import ValidationError |
| 10 | + |
| 11 | +# these type aliases do not exist at runtime, they're only defined here in the stub |
| 12 | +_JSON_OBJECT = Mapping[str, Any] |
| 13 | +_JSON_VALUE: TypeAlias = _JSON_OBJECT | list[Any] | str | int | float | bool | None |
| 14 | +_ValidatorCallback: TypeAlias = Callable[[Any, Any, _JSON_VALUE, _JSON_OBJECT], Iterator[ValidationError]] |
7 | 15 |
|
8 | 16 | _Schema: TypeAlias = Mapping[str, Any] |
9 | 17 |
|
@@ -33,13 +41,13 @@ class _Validator: |
33 | 41 |
|
34 | 42 | def validates(version: str) -> Callable[..., Any]: ... |
35 | 43 | def create( |
36 | | - meta_schema, |
37 | | - validators=..., |
| 44 | + meta_schema: Mapping[str, Any], |
| 45 | + validators: Mapping[str, _ValidatorCallback] = ..., |
38 | 46 | version: Any | None = ..., |
39 | | - type_checker=..., |
40 | | - format_checker=..., |
41 | | - id_of=..., |
42 | | - applicable_validators=..., |
| 47 | + type_checker: TypeChecker = ..., |
| 48 | + format_checker: FormatChecker = ..., |
| 49 | + id_of: Callable[[bool | _JSON_OBJECT], str] = ..., |
| 50 | + applicable_validators: Callable[[_JSON_OBJECT], Iterable[tuple[str, _ValidatorCallback]]] = ..., |
43 | 51 | ) -> type[_Validator]: ... |
44 | 52 | def extend( |
45 | 53 | validator, validators=..., version: Any | None = ..., type_checker: Any | None = ..., format_checker: Any | None = ... |
|
0 commit comments