Registry / serialization / optionaldict

optionaldict

JSON →
library0.1.2pypypi✓ verified 84d ago

A dict subclass that silently ignores NoneType values when setting items, useful for cleaning up API payloads or configurations. Current version 0.1.2, no recent releases (last in 2015), effectively in maintenance mode.

pip install optionaldict
INSTALL
IMPORT
SIG · OPTIONALDICT
O
optionaldict
serializationpythonv0.1.2
Install
2.0s 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 v0.1.2 · 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 2.0s · import 0.000s · 18MB
16MB installed
● package 16MB
Code
Verified usage

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

OptionalDict
from optionaldict import OptionalDict
No common wrong import; the package is simple.

Create an OptionalDict, set keys with None values are ignored.

from optionaldict import OptionalDict d = OptionalDict() d['key1'] = 'value1' d['key2'] = None # This assignment is silently ignored d['key3'] = 'value3' print(dict(d)) # Output: {'key1': 'value1', 'key3': 'value3'}
Debug
Known issues
gotchaOptionalDict does not ignore None on initialization from another dict with None values; only assignments via __setitem__ are filtered.
fix
After creating OptionalDict from a regular dict, manually reassign keys to trigger filtering, or use dict comprehension.
affects: all
gotchaOptionalDict only checks for None, not other falsy values like empty string, 0, or False.
fix
If you need to ignore other falsy values, subclass or wrap OptionalDict.
affects: all
Errors
Common errors & fixes
AttributeError: module 'optionaldict' has no attribute 'OptionalDict'
Importing with wrong casing or using old style import.
fix
Use: from optionaldict import OptionalDict
Upgrade
Version history
0.1.2latest on PyPI · released Jan 15, 2021
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
optionaldict — pip install optionaldict · libregistry