niltype
A singleton Nil object to represent missing values when None is a valid data value
What it is and what it does
NilType provides a `Nil` singleton—a distinct sentinel value for representing the absence of data when `None` itself is a meaningful value in your data model. This solves a real problem in Python: when your domain allows `None` as a valid entry (e.g., a database field that can legitimately store null), you need a separate marker to mean 'no value provided' or 'undefined'. The package exports `Nil` for identity checks and a `Nilable` type alias for type annotations.
The typical use case is function signatures where you want to distinguish between an explicit `None` argument and no argument at all. For example, a `get()` function can use `Nil` as its default parameter value, then check `if default is not Nil` to know whether the caller passed something. The package is minimal—no dependencies, pure Python, and typed—making it a lightweight addition to any codebase that needs this pattern.
Use it for:
- Default function parameters: distinguish between an explicit `None` and an unspecified argument using `Nil` as the default.
- Data model fields: represent missing or undefined values in classes or dataclasses where `None` is a valid stored value.
- Optional configuration: mark configuration values as explicitly unset (Nil) versus set to None or a default.
- Type-hinted optional values: use `Nilable[T]` in function signatures to document that a value can be a type or Nil.
- Sentinel-based control flow: use identity checks (`is Nil`) to branch on whether a value was explicitly provided.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides a `Nil` singleton object to represent missing or undefined values in situations where `None` is itself a valid data value and cannot be used as a sentinel.
Yes, if you have a codebase where `None` is a valid data value and you need a distinct sentinel. The package is tiny, has no dependencies, is MIT-licensed, and solves a real semantic problem. Dormant maintenance is not a concern for a single-purpose utility with no external dependencies. Install it if the pattern fits your domain; skip it if you can use a different sentinel (e.g., a custom class) or if `None` is always sufficient.
Install
niltype on PyPI
pip
pip install niltypeuv
uv add niltypepoetry
poetry add niltypeInstalling niltype
Before you install
Low friction: pure Python wheel with no runtime dependencies. Maintenance is dormant—last commit was 2024-09-21 and no activity since, though the repository remains open and the package is typed.
License in practice
MIT license (permissive) places no restrictions on use, modification, or redistribution in commercial or private projects.
Quickstart
pip install niltype
from niltype import Nil
if x is Nil:
print("x is missing")
Verify before relying
- Whether Nil works correctly with type checkers (mypy, pyright) beyond the Nilable type alias provided
- Performance characteristics when used in tight loops or large data structures
- Compatibility with pickle, dataclass, or other serialization frameworks
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.8) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | dormant — 692 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 100,117/month — #13,001 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: niltype-1.0.2-py3-none-any.whl
Tags
More Software Development packages
Provides backported and experimental type hints…
permissive · top 100 on PyPI
numpyNumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
fastapiFastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
distlibDistlib provides low-level packaging utilities…
permissive · top 1,000 on PyPI
sentinelCreates singleton sentinel objects that…
permissive · top 15,000 on PyPI
nulltypeDefines custom null and sentinel values that…
permissive · top 5,000 on PyPI
sentinelsProvides singleton sentinel objects with…
permissive · top 5,000 on PyPI
func_argsProvides sentinel values (REQ and OPT) and…
permissive · top 5,000 on PyPI
solusProvides thread-safe and thread-unsafe…
permissive · top 15,000 on PyPI
Redis-Sentinel-UrlParses redis:// and redis+sentinel:// URLs and…
permissive · top 15,000 on PyPI
singleton-decoratorProvides a decorator that enforces singleton…
copyleft · top 15,000 on PyPI
pyjon.utilsProvides utility classes for Python…
permissive · top 15,000 on PyPI
redis-cliProvides a lightweight wrapper around redis-py…
permissive · top 15,000 on PyPI
resultProvides a Rust-inspired Result type for Python…
permissive · top 5,000 on PyPI