Skip to content

Typing

OptionalPredicate = Optional[Predicate[T]] module-attribute

Represents optional predicates.

Passing None is equivalent to passing bool, though most functions are optimized to reduce the overhead of calling bool.

Sum

Bases: Protocol

Represents types for which adding self: S to other: S returns S.

Source code in iters/typing.py
20
21
22
23
24
25
26
@runtime_checkable
class Sum(Protocol):
    """Represents types for which adding `self: S` to `other: S` returns `S`."""

    @required
    def __add__(self, __other: Self) -> Self:
        raise NotImplementedError

Product

Bases: Protocol

Represents types for which multiplying self: P with other: P returns P.

Source code in iters/typing.py
29
30
31
32
33
34
35
@runtime_checkable
class Product(Protocol):
    """Represents types for which multiplying `self: P` with `other: P` returns `P`."""

    @required
    def __mul__(self, __other: Self) -> Self:
        raise NotImplementedError