skillfed

niltype

A singleton Nil object to represent missing values when None is a valid data value

niltype v1.0.2 100.1K downloads/30d#13,001 on PyPI1
Permissive license MIT DORMANT released

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 niltype

uv

uv add niltype

poetry

poetry add niltype

Installing 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

License :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Typing :: Typed

Tags

sentinel value for missing datanil object pythondistinguish none from missingnull placeholder when none is validoptional value without overloading nonemissing data representation
sentinel-valuetype-hints

More Software Development packages