{"id":21664,"library":"optionaldict","title":"optionaldict","description":"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.","status":"maintenance","version":"0.1.2","language":"python","source_language":"en","source_url":"https://github.com/messense/optionaldict","tags":["dict","none","filter","utility","python"],"install":[{"cmd":"pip install optionaldict","lang":"bash","label":"Install via pip"}],"dependencies":[],"imports":[{"note":"No common wrong import; the package is simple.","symbol":"OptionalDict","correct":"from optionaldict import OptionalDict"}],"quickstart":{"code":"from optionaldict import OptionalDict\n\nd = OptionalDict()\nd['key1'] = 'value1'\nd['key2'] = None  # This assignment is silently ignored\nd['key3'] = 'value3'\nprint(dict(d))  # Output: {'key1': 'value1', 'key3': 'value3'}","lang":"python","description":"Create an OptionalDict, set keys with None values are ignored."},"warnings":[{"fix":"After creating OptionalDict from a regular dict, manually reassign keys to trigger filtering, or use dict comprehension.","message":"OptionalDict does not ignore None on initialization from another dict with None values; only assignments via __setitem__ are filtered.","severity":"gotcha","affected_versions":"all"},{"fix":"If you need to ignore other falsy values, subclass or wrap OptionalDict.","message":"OptionalDict only checks for None, not other falsy values like empty string, 0, or False.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Use: from optionaldict import OptionalDict","cause":"Importing with wrong casing or using old style import.","error":"AttributeError: module 'optionaldict' has no attribute 'OptionalDict'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}