|
11 | 11 | """Stub file containing a skeleton of the public interface of `pydantic` library"""
|
12 | 12 |
|
13 | 13 | from abc import ABCMeta
|
14 |
| -from typing import Any, Literal, Generator, Mapping, Set, Tuple, TypeAlias, Union |
15 |
| -from typing_extensions import Annotated, Self |
| 14 | +from typing import ( |
| 15 | + Any, |
| 16 | + Callable, |
| 17 | + Literal, |
| 18 | + Generator, |
| 19 | + Mapping, |
| 20 | + Protocol, |
| 21 | + Set, |
| 22 | + Tuple, |
| 23 | + TypeAlias, |
| 24 | + TypeVar, |
| 25 | + Union, |
| 26 | +) |
| 27 | +from typing_extensions import Annotated, Generic, Self |
| 28 | + |
| 29 | +_ModelType = TypeVar("_ModelType") |
| 30 | +IncEx: TypeAlias = Union[ |
| 31 | + Set[int], Set[str], Mapping[int, Union["IncEx", bool]], Mapping[str, Union["IncEx", bool]] |
| 32 | +] |
| 33 | +ModelAfterValidator = Callable[[_ModelType, ValidationInfo], _ModelType] |
| 34 | +ModelAfterValidatorWithoutInfo = Callable[[_ModelType], _ModelType] |
| 35 | +StrictBool = Annotated[bool, ...] |
| 36 | +StrictInt = Annotated[int, ...] |
| 37 | +StrictStr = Annotated[str, ...] |
| 38 | +ReturnType = TypeVar("ReturnType") |
| 39 | +TupleGenerator: TypeAlias = Generator[Tuple[str, Any], None, None] |
16 | 40 |
|
17 | 41 | class BaseModel(metaclass=ABCMeta):
|
18 | 42 | def __iter__(self) -> TupleGenerator: ...
|
@@ -40,15 +64,18 @@ class BaseModel(metaclass=ABCMeta):
|
40 | 64 | context: Any | None = None,
|
41 | 65 | ) -> Self: ...
|
42 | 66 |
|
43 |
| -IncEx: TypeAlias = Union[ |
44 |
| - Set[int], Set[str], Mapping[int, Union["IncEx", bool]], Mapping[str, Union["IncEx", bool]] |
45 |
| -] |
46 |
| -StrictBool = Annotated[bool, ...] |
47 |
| -StrictInt = Annotated[int, ...] |
48 |
| -StrictStr = Annotated[str, ...] |
49 |
| -TupleGenerator: TypeAlias = Generator[Tuple[str, Any], None, None] |
50 |
| - |
| 67 | +class ModelValidatorDecoratorInfo(metaclass=ABCMeta): ... |
| 68 | +class PydanticDescriptorProxy(Generic[ReturnType], metaclass=ABCMeta): ... |
51 | 69 | class ValidationError(ValueError, metaclass=ABCMeta): ...
|
| 70 | +class ValidationInfo(Protocol, metaclass=ABCMeta): ... |
| 71 | + |
| 72 | +_AnyModelAfterValidator = Union[ |
| 73 | + ModelAfterValidator[_ModelType], ModelAfterValidatorWithoutInfo[_ModelType] |
| 74 | +] |
52 | 75 |
|
53 | 76 | def create_model(model_name: str) -> type[BaseModel]: ...
|
54 |
| -def model_validator(*, mode: Literal["wrap", "before", "after"]) -> Any: ... |
| 77 | +def model_validator( |
| 78 | + *, mode: Literal["after"] |
| 79 | +) -> Callable[ |
| 80 | + [_AnyModelAfterValidator[_ModelType]], PydanticDescriptorProxy[ModelValidatorDecoratorInfo] |
| 81 | +]: ... |
0 commit comments