Sentinel value for missing data where None has its own meaning
Project description
no-value
Sentinel value to express missing keys or values where None has its own meaning.
Why?
When building APIs or update operations, you often need to distinguish between:
- a value — set the field
None— clear the field- not provided — leave the field unchanged
Python's None can't cover both "clear" and "not provided". NoValue fills that gap.
Installation
pip install no-value
Usage
from no_value import NoValue
def update_user(name: str | None | NoValue = NoValue) -> None:
if name is NoValue:
pass # not provided, do nothing
elif name is None:
clear_name() # explicitly set to null
else:
set_name(name) # update with new value
Behavior
- Use
isfor comparison:val is NoValue str(NoValue)andrepr(NoValue)return"NoValue"NoValue()raisesTypeError— it cannot be instantiatedbool(NoValue)raisesTypeError— to prevent accidental truthy/falsy checks
Limitations
Static analysis tools (mypy, pyright) do not fully support custom sentinel types. Type annotations like str | None | NoValue work at runtime but may produce warnings in strict mode.
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file no_value-1.0.0.tar.gz.
File metadata
- Download URL: no_value-1.0.0.tar.gz
- Upload date:
- Size: 4.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a42e471581a043ace99038a6ae0f38f994d13f9a5ba6196ad3298b4f06943193
|
|
| MD5 |
569879ceaaa82197d85196c43ae63997
|
|
| BLAKE2b-256 |
e694857e3e987a1b8100df299efb2ac54f5fae8e854cc31860c4ea281986120c
|
Provenance
The following attestation bundles were made for no_value-1.0.0.tar.gz:
Publisher:
publish-pypi.yml on miriada-io/no-value
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
no_value-1.0.0.tar.gz -
Subject digest:
a42e471581a043ace99038a6ae0f38f994d13f9a5ba6196ad3298b4f06943193 - Sigstore transparency entry: 1328603501
- Sigstore integration time:
-
Permalink:
miriada-io/no-value@0ca55cd4e43a7a7bf0f904cc2491b008ea135648 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/miriada-io
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@0ca55cd4e43a7a7bf0f904cc2491b008ea135648 -
Trigger Event:
release
-
Statement type:
File details
Details for the file no_value-1.0.0-py3-none-any.whl.
File metadata
- Download URL: no_value-1.0.0-py3-none-any.whl
- Upload date:
- Size: 3.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
830d356747ed04b6802c33a2aaefe32a15da7fd8720915ad614231c548a7812e
|
|
| MD5 |
d38ea6773d32017edbb4b3ef2905e83a
|
|
| BLAKE2b-256 |
878aba20ef5a872c66a3734c08542e890888613d4afa844cb1f83e069a32885a
|
Provenance
The following attestation bundles were made for no_value-1.0.0-py3-none-any.whl:
Publisher:
publish-pypi.yml on miriada-io/no-value
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
no_value-1.0.0-py3-none-any.whl -
Subject digest:
830d356747ed04b6802c33a2aaefe32a15da7fd8720915ad614231c548a7812e - Sigstore transparency entry: 1328603506
- Sigstore integration time:
-
Permalink:
miriada-io/no-value@0ca55cd4e43a7a7bf0f904cc2491b008ea135648 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/miriada-io
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@0ca55cd4e43a7a7bf0f904cc2491b008ea135648 -
Trigger Event:
release
-
Statement type: