Skip to content

Types

infinity = Infinity() module-attribute

The singleton instance of Infinity.

negative_infinity = NegativeInfinity() module-attribute

The singleton instance of NegativeInfinity.

AnyInfinity = Union[Infinity, NegativeInfinity] module-attribute

The union of Infinity and NegativeInfinity.

Infinity

Bases: Singleton

Represents the positive infinity.

Source code in versions/types.py
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
class Infinity(Singleton):
    """Represents the positive infinity."""

    def __repr__(self) -> str:
        return INFINITY

    def __eq__(self, other: Any) -> bool:
        return self is other

    def __ne__(self, other: Any) -> bool:
        return self is not other

    def __lt__(self, other: Any) -> bool:
        return False

    def __le__(self, other: Any) -> bool:
        return self is other

    def __gt__(self, other: Any) -> bool:
        return self is not other

    def __ge__(self, other: Any) -> bool:
        return True

    def __neg__(self: Infinity) -> NegativeInfinity:
        return negative_infinity

NegativeInfinity

Bases: Singleton

Represents the negative infinity.

Source code in versions/types.py
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
class NegativeInfinity(Singleton):
    """Represents the negative infinity."""

    def __repr__(self) -> str:
        return NEGATIVE_INFINITY

    def __eq__(self, other: Any) -> bool:
        return self is other

    def __ne__(self, other: Any) -> bool:
        return self is not other

    def __lt__(self, other: Any) -> bool:
        return self is not other

    def __le__(self, other: Any) -> bool:
        return True

    def __gt__(self, other: Any) -> bool:
        return False

    def __ge__(self, other: Any) -> bool:
        return self is other

    def __neg__(self: NegativeInfinity) -> Infinity:
        return infinity

is_infinity(item: Any) -> TypeGuard[Infinity]

Checks if an item is an instance of Infinity.

Returns:

Type Description
TypeGuard[Infinity]

Whether the item is an instance of Infinity.

Source code in versions/types.py
61
62
63
64
65
66
67
def is_infinity(item: Any) -> TypeGuard[Infinity]:
    """Checks if an `item` is an instance of [`Infinity`][versions.types.Infinity].

    Returns:
        Whether the `item` is an instance of [`Infinity`][versions.types.Infinity].
    """
    return item is infinity

is_negative_infinity(item: Any) -> TypeGuard[NegativeInfinity]

Checks if an item is an instance of NegativeInfinity.

Returns:

Type Description
TypeGuard[NegativeInfinity]

Whether the item is an instance of NegativeInfinity.

Source code in versions/types.py
102
103
104
105
106
107
108
def is_negative_infinity(item: Any) -> TypeGuard[NegativeInfinity]:
    """Checks if an `item` is an instance of [`NegativeInfinity`][versions.types.NegativeInfinity].

    Returns:
        Whether the `item` is an instance of [`NegativeInfinity`][versions.types.NegativeInfinity].
    """
    return item is negative_infinity

is_any_infinity(item: Any) -> TypeGuard[AnyInfinity]

Checks if an item is an instance of AnyInfinity.

Returns:

Type Description
TypeGuard[AnyInfinity]

Whether the item is an instance of AnyInfinity.

Source code in versions/types.py
117
118
119
120
121
122
123
def is_any_infinity(item: Any) -> TypeGuard[AnyInfinity]:
    """Checks if an `item` is an instance of [`AnyInfinity`][versions.types.AnyInfinity].

    Returns:
        Whether the `item` is an instance of [`AnyInfinity`][versions.types.AnyInfinity].
    """
    return item is infinity or item is negative_infinity