Skip to main content
Package Version PyPI - Status Tests Status Code Coverage Percentage Project License Python Versions

🕳️ A Python library package which provides a sentinel for absent values - a falsey, immutable singleton that represents the absence of a value in contexts where None or False may be valid values.

Key Features ⭐

  • 1️⃣ Absence Sentinel: A falsey singleton which represents absence.

  • 🏭 Absence Factory: Create custom absence sentinels for package-specific or arbitrary needs.

  • 📦 Absence Cell: Immutable container wrapping absent values with conditional extraction, evaluation, and transformation API.

  • 𝒇 Predicate Functions: Determine if a value is absent.

  • 🔍 Type Support: Type alias for optional values which may be absent. (Similar to typing.Optional and its relation to None.)

  • 🌟 Builtins Integration: Can install singleton and predicate function into Python builtins.

Installation 📦

pip install absence

Examples 💡

Use the absent sentinel to represent missing values:

>>> from dataclasses import dataclass
>>> from absence import absent, is_present, Absential
>>> @dataclass
... class User:
...     name: str | None
...     email: str | None
>>> def apply_partial_update(
...     user: User,
...     name: Absential[ str | None ] = absent,
...     email: Absential[ str | None ] = absent,
... ) -> User:
...     ''' Updates user fields if values provided.
...
...         Absent value means "don't change".
...         None value means "clear field".
...     '''
...     if is_present( name ): user.name = name
...     if is_present( email ): user.email = email
...     return user
>>> user = User( name = 'Alice', email = 'alice@example.com' )
>>> # Clear name but leave email unchanged
>>> updated = apply_partial_update( user, name = None )
>>> updated.name  # Cleared to None
>>> updated.email  # Unchanged
'alice@example.com'
>>> # Update both fields
>>> updated = apply_partial_update( user, name = 'Bob', email = 'bob@example.com' )
>>> updated.name
'Bob'
>>> updated.email
'bob@example.com'

Create package-specific absence sentinels:

>>> from absence import AbsenceFactory
>>> MISSING = AbsenceFactory( )
>>> bool( MISSING )
False

Wrap absent values with AbsenceCell for conditional chains:

>>> from absence import AbsenceCell, absent, Absential
>>> def adjust_columns( width: Absential[ int ] ) -> int:
...     ''' Returns adjusted width, or 0 if width is absent. '''
...     return AbsenceCell( width ).evaluate_or( lambda w: w - 4, 0 )
>>> adjust_columns( 80 )
76
>>> adjust_columns( absent )
0

Use Cases 🎯

  • 🔄 Optional Arguments: When None is a valid argument value but you need to detect absence.

  • 🎯 Sentinel Values: When you need a unique, falsey object to represent missing or invalid states.

  • 🧩 Type Safety: When you want explicit typing for values that may be absent.

Comparison with Alternatives 🤔

Alternative

Truthy?

Unique?

Picklable?

Scope

object()

Yes

Yes

No

Arbitrary

PEP 661 Sentinels

Optional

Yes

Yes

Per-Module

dataclasses.MISSING

Yes

Yes

No

Global

typing.NoDefault

Yes

Yes

Yes

Global

absence.absent

No

Yes

No

Global

The absent sentinel combines falsey behavior with global uniqueness, making it particularly suitable for representing missing values in contexts where None might be a valid value. The companion AbsenceFactory allows creation of arbitrary absence sentinels, when needed, such as for specific packages.

See PEP 661 (“Sentinel Values”), typing.NoDefault, and dataclasses.MISSING for more details on alternatives.

Installation 📦

Method: Install Python Package

Install via uv pip command:

uv pip install absence

Or, install via pip:

pip install absence

Contribution 🤝

Contribution to this project is welcome! However, it must follow the code of conduct for the project.

Please file bug reports and feature requests in the issue tracker or submit pull requests to improve the source code or documentation.

For development guidance and standards, please see the development guide.

Additional Indicia

GitHub last commit Copier Hatch pre-commit Pyright Ruff PyPI - Implementation PyPI - Wheel

Other Projects by This Author 🌟

  • python-accretive (accretive on PyPI)

    🌌 A Python library package which provides accretive data structures - collections which can grow but never shrink.

  • python-classcore (classcore on PyPI)

    🏭 A Python library package which provides foundational class factories and decorators for providing classes with attributes immutability and concealment and other custom behaviors.

  • python-detextive (detextive on PyPI)

    🕵️ A Python library which provides consolidated text detection capabilities for reliable content analysis. Offers MIME type detection, character set detection, and line separator processing.

  • python-dynadoc (dynadoc on PyPI)

    📝 A Python library package which bridges the gap between rich annotations and automatic documentation generation with configurable renderers and support for reusable fragments.

  • python-falsifier (falsifier on PyPI)

    🎭 A very simple Python library package which provides a base class for falsey objects - objects that evaluate to False in boolean contexts.

  • python-frigid (frigid on PyPI)

    🔒 A Python library package which provides immutable data structures - collections which cannot be modified after creation.

  • python-icecream-truck (icecream-truck on PyPI)

    🍦 Flavorful Debugging - A Python library which enhances the powerful and well-known icecream package with flavored traces, configuration hierarchies, customized outputs, ready-made recipes, and more.

  • python-librovore (librovore on PyPI)

    🐲 Documentation Search Engine - An intelligent documentation search and extraction tool that provides both a command-line interface for humans and an MCP (Model Context Protocol) server for AI agents. Search across Sphinx and MkDocs sites with fuzzy matching, extract clean markdown content, and integrate seamlessly with AI development workflows.

  • python-mimeogram (mimeogram on PyPI)

    📨 A command-line tool for exchanging collections of files with Large Language Models - bundle multiple files into a single clipboard-ready document while preserving directory structure and metadata… good for code reviews, project sharing, and LLM interactions.

Metadata

Release files for absence 1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for absence 1.2
File Size Uploaded
absence-1.2.tar.gz 17.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for absence 1.2
File Interpreter ABI Platform
absence-1.2-py3-none-any.whl Python 3 none any Details

Total release size: 38.7 kB

Release files / absence-1.2.tar.gz

Download URL absence-1.2.tar.gz
Size 17.5 kB
Tags Source
SHA-256 checksum
How to use checksums
68d031662a51d5d2c994b53d28ba7fb4cc06373ee3611339b9478e6b89b57133
BLAKE2b-256 checksum
How to use checksums
04e1017f2cc97727fa44577cbfc0aaa310998481db2413edcb56204f65d65798
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 8, 2026.

Transparency log

Release files / absence-1.2-py3-none-any.whl

Download URL absence-1.2-py3-none-any.whl
Size 21.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ed95d897910beb1418b03070f4d0946c14a697988fe19682fb78e930f1ff32f7
BLAKE2b-256 checksum
How to use checksums
5cf4c2e50357e8f227b91d11cd503983792decec4a87ea4faa44f882cc6feb2b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 8, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

1.2 This release

2 release files

1.1.1

2 release files

1.1

2 release files

1.0.1

2 release files

1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page