API¶
Package absence¶
A sentinel for absent values, distinct from None, with support for creating
package-specific absence sentinels. Particularly useful in contexts where
None is a valid value but you need to detect the absence of a value.
absent: Global sentinel representing absence, with falsey behavior and identity-based equality.AbsenceFactory: Creates package-specific absence sentinels with customizable string representations.Absential: Type alias for values that may be absent, supporting clear type hints.is_absent: Type-safe predicate for checking if a value is the global absence sentinel.is_absence: Type-safe predicate for checking if a value is any absence sentinel.install: Optional function to install absence sentinel and predicates as builtins.
Module absence.objects¶
Absence sentinel factory, global singleton, and helper functions.
- class absence.objects.AbsenceFactory(repr_function: Annotated[Callable[[Self], str] | None, Doc(' Function for __repr__. ')] | None = None, str_function: Annotated[Callable[[Self], str] | None, Doc(' Function for __str__. ')] | None = None)¶
Bases:
FalsifierProduces arbitrary absence sentinels.
- class absence.objects.AbsentSingleton¶
Bases:
AbsenceFactoryProduces global absence sentinel.
- absence.objects.is_absence(value: object) TypeIs[AbsenceFactory]¶
Checks if value is an absence sentinel.
- absence.objects.is_absent(value: object) TypeIs[AbsentSingleton]¶
Checks if value is the global absence sentinel.
Module absence.installers¶
Convenience to expose global sentinel and sentinel checker in builtins.
- absence.installers.install(sentinel_name: Annotated[str | None, Doc(' Name to use for sentinel in builtins. ``None`` to skip. ')] = 'Absent', predicate_name: Annotated[str | None, Doc(' Name to use for predicate in builtins. ``None`` to skip. ')] = 'isabsent') None¶
Installs absence sentinel and predicate as builtins.
Module absence.exceptions¶
Family of exceptions for package API.
Omniexception: Base for all package exceptionsOmnierror: Base for all package errors
- exception absence.exceptions.Omnierror¶
Bases:
Omniexception,ExceptionBase for error exceptions raised by package API.
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- args¶
- exception absence.exceptions.Omniexception¶
Bases:
ImmutableObject,BaseExceptionBase for all exceptions raised by package API.
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- args¶