| 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[ |
| 55 |
_ValidatorType[_T], List[_ValidatorType[_T]], Tuple[_ValidatorType[_T]] |
| 56 |
] |
| 57 |
) -> _ValidatorType[Optional[_T]]: ... |
| 58 |
def in_(options: Container[_T]) -> _ValidatorType[_T]: ... |
| 59 |
def and_(*validators: _ValidatorType[_T]) -> _ValidatorType[_T]: ... |
| 60 |
def matches_re( |
| 61 |
regex: Union[Pattern[AnyStr], AnyStr], |
| 62 |
flags: int = ..., |
| 63 |
func: Optional[ |
| 64 |
Callable[[AnyStr, AnyStr, int], Optional[Match[AnyStr]]] |
| 65 |
] = ..., |
| 66 |
) -> _ValidatorType[AnyStr]: ... |
| 67 |
def deep_iterable( |
| 68 |
member_validator: _ValidatorArgType[_T], |
| 69 |
iterable_validator: Optional[_ValidatorType[_I]] = ..., |
| 70 |
) -> _ValidatorType[_I]: ... |
| 71 |
def deep_mapping( |
| 72 |
key_validator: _ValidatorType[_K], |
| 73 |
value_validator: _ValidatorType[_V], |
| 74 |
mapping_validator: Optional[_ValidatorType[_M]] = ..., |
| 75 |
) -> _ValidatorType[_M]: ... |
| 76 |
def is_callable() -> _ValidatorType[_T]: ... |
| 77 |
def lt(val: _T) -> _ValidatorType[_T]: ... |
| 78 |
def le(val: _T) -> _ValidatorType[_T]: ... |
| 79 |
def ge(val: _T) -> _ValidatorType[_T]: ... |
| 80 |
def gt(val: _T) -> _ValidatorType[_T]: ... |
| 81 |
def max_len(length: int) -> _ValidatorType[_T]: ... |
| 82 |
def min_len(length: int) -> _ValidatorType[_T]: ... |
| 83 |
def not_( |
| 84 |
validator: _ValidatorType[_T], |
| 85 |
*, |
| 86 |
msg: Optional[str] = None, |
| 87 |
exc_types: Union[Type[Exception], Iterable[Type[Exception]]] = ..., |
| 88 |
) -> _ValidatorType[_T]: ... |