Skip to content

Exceptions

typed_sentinels._exceptions

Classes

SentinelError

Bases: TypeError

Base class from which all typed_sentinels Exception objects inherit.

InvalidHintError

InvalidHintError(hint: Any)

Bases: SentinelError

Argument for hint must not be Sentinel, Ellipsis, True, False, None, or a Sentinel instance.

Initialize InvalidHintError.

Parameters:

Name Type Description Default
hint Any

The invalid argument for hint as provided to the Sentinel class constructor.

required
Source code in src/typed_sentinels/_exceptions.py
def __init__(self, hint: Any, /) -> None:
    """Initialize `InvalidHintError`.

    Parameters
    ----------
    hint : Any
        The invalid argument for `hint` as provided to the `Sentinel` class constructor.
    """
    msg = 'Argument for `hint` must not be `None`\n'
    if hint is not None:
        msg = 'Argument for `hint` must not be any of: '
        msg += '`Sentinel`, `Ellipsis`, `True`, `False`, `None`, or a `Sentinel` instance\n'
    msg += f"Received argument for hint: '{hint!r}'"
    super().__init__(msg)
Functions

SubscriptedTypeError

SubscriptedTypeError(hint: Any, subscripted: Any)

Bases: SentinelError

Subscripted type and hint must match.

Initialize SubscriptedTypeError.

Parameters:

Name Type Description Default
hint Any

Provided argument for hint.

required
subscripted Any

Type provided via subscription notation to the Sentinel class object.

required
Source code in src/typed_sentinels/_exceptions.py
def __init__(self, hint: Any, subscripted: Any) -> None:
    """Initialize `SubscriptedTypeError`.

    Parameters
    ----------
    hint : Any
        Provided argument for `hint`.
    subscripted : Any
        Type provided via subscription notation to the `Sentinel` class object.
    """
    msg = 'Subscripted type and `hint` must match\n'
    msg += f'   Subscripted type: {subscripted!r}\n'
    msg += f'               Hint: {hint!r}'
    super().__init__(msg)
Functions