Registry / serialization / nulltype

nulltype

JSON →
library2.3.1pypypi✓ verified 23d ago

nulltype is a Python library (current version 2.3.1) that provides custom null values and sentinels, distinct from Python's built-in `None`, `False`, or `True`. It helps represent different states of 'emptiness' or 'undefined' values, such as `Passthrough`, `Prohibited`, or `Undefined`, without overloading standard Python nullish objects. The library aims to simplify code by allowing robust handling of potentially missing data in a consistent way. The last release was in June 2018, indicating a maintenance phase with infrequent updates.

pip install nulltype
INSTALL
IMPORT
SIG · NULLTYPE
N
nulltype
serializationpythonv2.3.1
Install
1.6s avg
Import
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v2.3.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 17.8MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.6s · import 0.000s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

NullType
from nulltype import NullType
Empty
from nulltype import Empty
Null
from nulltype import Null
Nothing
from nulltype import Nothing

Demonstrates how to create a custom `NullType` and its behavior when subjected to common Python operations (boolean evaluation, length, iteration, attribute access, item access, and calls). It also shows the use of the pre-defined `Empty`, `Nothing`, and `Null` sentinels.

from nulltype import NullType, Empty, Nothing, Null # Create a custom null type Undefined = NullType('Undefined') # Test common Pythonic behaviors assert bool(Undefined) is False assert len(Undefined) == 0 assert list(Undefined) == [] # Accessing attributes, items, or calling a NullType instance # By default, for custom NullTypes, attribute/call access returns Empty, and item access returns Nothing. # For predefined sentinels like Empty, these operations return themselves. assert Undefined.some_attribute is Empty assert Undefined[22] is Nothing assert Undefined("hey", 12) is Empty # Using pre-defined sentinels assert Empty.any_attr is Empty assert Nothing[0] is Nothing assert Null() is Null print("NullType examples ran successfully!")
Debug
Known issues
gotchaNullType instances are intended to be singletons (one per program) but their uniqueness is not strictly enforced. While this is rarely an issue in practice, users should be mindful that multiple instances with the same name could technically exist if not careful with usage patterns.
fix
Rely on the convention of creating each NullType once, typically at module level, to ensure single instance behavior.
affects: 2.0.0 and later
gotchaThe library was last released in 2018 and was explicitly tested up to Python 3.7 pre-release. While generally compatible with newer Python versions, it is not actively tested against Python 3.8+ versions. Users on recent Python versions should verify compatibility, especially concerning subtle changes in built-in behaviors or type hinting.
fix
Test your application's usage of `nulltype` thoroughly when upgrading to newer Python environments. Consider alternatives if explicit compatibility with the latest Python features or type hinting is critical.
affects: Python 3.8 and later (untested)
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'nulltype'
The 'nulltype' package is not installed in the current Python environment or is not accessible via the Python path.
fix
Install the package using pip: `pip install nulltype`
AttributeError: module 'nulltype' has no attribute 'passthrough'
The user is attempting to access a custom null value like 'Passthrough' with incorrect capitalization (e.g., lowercase 'p') or before explicitly importing it, leading Python to report that the module does not have that attribute.
fix
Ensure correct capitalization when accessing the custom null values (e.g., `nulltype.Passthrough`) or import them directly: `from nulltype import Passthrough`
AttributeError: 'Passthrough' object has no attribute 'some_method'
A custom null value object (like `Passthrough`) is being treated as a regular object with methods, but it is a simple sentinel and does not define the called attribute or method.
fix
Custom null value objects from `nulltype` are sentinels and do not have arbitrary methods. Avoid calling methods on them; instead, use identity checks (e.g., `if value is Passthrough:`) to handle their presence.
Upgrade
Version history
2.3.1latest on PyPI · released Jun 3, 2018
Audit
Dependencies

No dependency data recorded yet.

Agent activity
7 hits · last 30 days
node
6
Resources
nulltype — pip install nulltype · libregistry