mercurial/thirdparty/attr/validators.pyi
author Matt Harbison <matt_harbison@yahoo.com>
Wed, 01 Mar 2023 13:31:17 -0500
changeset 50379 3eacb4a54313
parent 49643 e1c586b9a43c
permissions -rw-r--r--
statichttprepo: unbyteify several IOError messages Builtin errors generally want str messages.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
49643
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
     1
from typing import (
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
     2
    Any,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
     3
    AnyStr,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
     4
    Callable,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
     5
    Container,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
     6
    ContextManager,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
     7
    Iterable,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
     8
    List,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
     9
    Mapping,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    10
    Match,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    11
    Optional,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    12
    Pattern,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    13
    Tuple,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    14
    Type,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    15
    TypeVar,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    16
    Union,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    17
    overload,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    18
)
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    19
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    20
from . import _ValidatorType
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    21
from . import _ValidatorArgType
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    22
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    23
_T = TypeVar("_T")
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    24
_T1 = TypeVar("_T1")
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    25
_T2 = TypeVar("_T2")
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    26
_T3 = TypeVar("_T3")
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    27
_I = TypeVar("_I", bound=Iterable)
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    28
_K = TypeVar("_K")
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    29
_V = TypeVar("_V")
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    30
_M = TypeVar("_M", bound=Mapping)
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    31
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    32
def set_disabled(run: bool) -> None: ...
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    33
def get_disabled() -> bool: ...
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    34
def disabled() -> ContextManager[None]: ...
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    35
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    36
# To be more precise on instance_of use some overloads.
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    37
# If there are more than 3 items in the tuple then we fall back to Any
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    38
@overload
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    39
def instance_of(type: Type[_T]) -> _ValidatorType[_T]: ...
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    40
@overload
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    41
def instance_of(type: Tuple[Type[_T]]) -> _ValidatorType[_T]: ...
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    42
@overload
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    43
def instance_of(
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    44
    type: Tuple[Type[_T1], Type[_T2]]
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    45
) -> _ValidatorType[Union[_T1, _T2]]: ...
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    46
@overload
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    47
def instance_of(
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    48
    type: Tuple[Type[_T1], Type[_T2], Type[_T3]]
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    49
) -> _ValidatorType[Union[_T1, _T2, _T3]]: ...
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    50
@overload
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    51
def instance_of(type: Tuple[type, ...]) -> _ValidatorType[Any]: ...
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    52
def provides(interface: Any) -> _ValidatorType[Any]: ...
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    53
def optional(
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    54
    validator: Union[_ValidatorType[_T], List[_ValidatorType[_T]]]
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    55
) -> _ValidatorType[Optional[_T]]: ...
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    56
def in_(options: Container[_T]) -> _ValidatorType[_T]: ...
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    57
def and_(*validators: _ValidatorType[_T]) -> _ValidatorType[_T]: ...
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    58
def matches_re(
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    59
    regex: Union[Pattern[AnyStr], AnyStr],
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    60
    flags: int = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    61
    func: Optional[
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    62
        Callable[[AnyStr, AnyStr, int], Optional[Match[AnyStr]]]
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    63
    ] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    64
) -> _ValidatorType[AnyStr]: ...
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    65
def deep_iterable(
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    66
    member_validator: _ValidatorArgType[_T],
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    67
    iterable_validator: Optional[_ValidatorType[_I]] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    68
) -> _ValidatorType[_I]: ...
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    69
def deep_mapping(
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    70
    key_validator: _ValidatorType[_K],
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    71
    value_validator: _ValidatorType[_V],
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    72
    mapping_validator: Optional[_ValidatorType[_M]] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    73
) -> _ValidatorType[_M]: ...
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    74
def is_callable() -> _ValidatorType[_T]: ...
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    75
def lt(val: _T) -> _ValidatorType[_T]: ...
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    76
def le(val: _T) -> _ValidatorType[_T]: ...
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    77
def ge(val: _T) -> _ValidatorType[_T]: ...
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    78
def gt(val: _T) -> _ValidatorType[_T]: ...
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    79
def max_len(length: int) -> _ValidatorType[_T]: ...
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    80
def min_len(length: int) -> _ValidatorType[_T]: ...