49643
|
1 from typing import (
|
|
2 Any,
|
|
3 AnyStr,
|
|
4 Callable,
|
|
5 Container,
|
|
6 ContextManager,
|
|
7 Iterable,
|
|
8 List,
|
|
9 Mapping,
|
|
10 Match,
|
|
11 Optional,
|
|
12 Pattern,
|
|
13 Tuple,
|
|
14 Type,
|
|
15 TypeVar,
|
|
16 Union,
|
|
17 overload,
|
|
18 )
|
|
19
|
|
20 from . import _ValidatorType
|
|
21 from . import _ValidatorArgType
|
|
22
|
|
23 _T = TypeVar("_T")
|
|
24 _T1 = TypeVar("_T1")
|
|
25 _T2 = TypeVar("_T2")
|
|
26 _T3 = TypeVar("_T3")
|
|
27 _I = TypeVar("_I", bound=Iterable)
|
|
28 _K = TypeVar("_K")
|
|
29 _V = TypeVar("_V")
|
|
30 _M = TypeVar("_M", bound=Mapping)
|
|
31
|
|
32 def set_disabled(run: bool) -> None: ...
|
|
33 def get_disabled() -> bool: ...
|
|
34 def disabled() -> ContextManager[None]: ...
|
|
35
|
|
36 # To be more precise on instance_of use some overloads.
|
|
37 # If there are more than 3 items in the tuple then we fall back to Any
|
|
38 @overload
|
|
39 def instance_of(type: Type[_T]) -> _ValidatorType[_T]: ...
|
|
40 @overload
|
|
41 def instance_of(type: Tuple[Type[_T]]) -> _ValidatorType[_T]: ...
|
|
42 @overload
|
|
43 def instance_of(
|
|
44 type: Tuple[Type[_T1], Type[_T2]]
|
|
45 ) -> _ValidatorType[Union[_T1, _T2]]: ...
|
|
46 @overload
|
|
47 def instance_of(
|
|
48 type: Tuple[Type[_T1], Type[_T2], Type[_T3]]
|
|
49 ) -> _ValidatorType[Union[_T1, _T2, _T3]]: ...
|
|
50 @overload
|
|
51 def instance_of(type: Tuple[type, ...]) -> _ValidatorType[Any]: ...
|
|
52 def provides(interface: Any) -> _ValidatorType[Any]: ...
|
|
53 def optional(
|
|
54 validator: Union[_ValidatorType[_T], List[_ValidatorType[_T]]]
|
|
55 ) -> _ValidatorType[Optional[_T]]: ...
|
|
56 def in_(options: Container[_T]) -> _ValidatorType[_T]: ...
|
|
57 def and_(*validators: _ValidatorType[_T]) -> _ValidatorType[_T]: ...
|
|
58 def matches_re(
|
|
59 regex: Union[Pattern[AnyStr], AnyStr],
|
|
60 flags: int = ...,
|
|
61 func: Optional[
|
|
62 Callable[[AnyStr, AnyStr, int], Optional[Match[AnyStr]]]
|
|
63 ] = ...,
|
|
64 ) -> _ValidatorType[AnyStr]: ...
|
|
65 def deep_iterable(
|
|
66 member_validator: _ValidatorArgType[_T],
|
|
67 iterable_validator: Optional[_ValidatorType[_I]] = ...,
|
|
68 ) -> _ValidatorType[_I]: ...
|
|
69 def deep_mapping(
|
|
70 key_validator: _ValidatorType[_K],
|
|
71 value_validator: _ValidatorType[_V],
|
|
72 mapping_validator: Optional[_ValidatorType[_M]] = ...,
|
|
73 ) -> _ValidatorType[_M]: ...
|
|
74 def is_callable() -> _ValidatorType[_T]: ...
|
|
75 def lt(val: _T) -> _ValidatorType[_T]: ...
|
|
76 def le(val: _T) -> _ValidatorType[_T]: ...
|
|
77 def ge(val: _T) -> _ValidatorType[_T]: ...
|
|
78 def gt(val: _T) -> _ValidatorType[_T]: ...
|
|
79 def max_len(length: int) -> _ValidatorType[_T]: ...
|
|
80 def min_len(length: int) -> _ValidatorType[_T]: ...
|