Skip to content

check

Functions:

is_soft_range

is_soft_range(val: Any) -> TypeIs[SoftRange]
Source code in jetpytools/types/check.py
18
19
20
21
22
23
def is_soft_range(val: Any) -> TypeIs[SoftRange]:
    return (
        isinstance(val, int)
        or is_strict_range(val)
        or (isinstance(val, Sequence) and all(isinstance(x, int) for x in val))
    )

is_soft_range_n

is_soft_range_n(val: Any) -> TypeIs[SoftRangeN]
Source code in jetpytools/types/check.py
26
27
28
29
30
31
def is_soft_range_n(val: Any) -> TypeIs[SoftRangeN]:
    return (
        isinstance(val, int)
        or (isinstance(val, tuple) and len(val) == 2 and all(isinstance(x, int) or x is None for x in val))
        or val is None
    )

is_soft_ranges_n

is_soft_ranges_n(val: Any) -> TypeIs[SoftRangesN]
Source code in jetpytools/types/check.py
34
35
def is_soft_ranges_n(val: Any) -> TypeIs[SoftRangesN]:
    return isinstance(val, Sequence) and all(is_soft_range_n(x) for x in val)

is_strict_range

is_strict_range(val: Any) -> TypeIs[StrictRange]
Source code in jetpytools/types/check.py
14
15
def is_strict_range(val: Any) -> TypeIs[StrictRange]:
    return isinstance(val, tuple) and len(val) == 2 and all(isinstance(x, int) for x in val)