Registry / serialization / unflatten

unflatten

JSON →
library0.2.0pypypi✓ verified 85d ago

Unflatten dicts to dicts with nested dicts/arrays. Current version 0.2.0. Release cadence: low (last release ~2021).

pip install unflatten
INSTALL
IMPORT
SIG · UNFLATTEN
U
unflatten
serializationpythonv0.2.0
Install
1.5s 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.2.0 · 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.5s · import 0.000s · 18MB
16MB installed
● package 16MB
Code
Verified usage

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

unflatten
from unflatten import unflatten
import unflatten
unflatten is a function, not a module. Use direct import.

Basic usage: unflatten a flat dict with dot-separated keys into nested dict.

from unflatten import unflatten flat = {'a.b.c': 1, 'a.b.d': 2, 'a.e': 3} result = unflatten(flat) print(result)
Debug
Known issues
breakingVersion 0.2.0 changed default delimiter from '.' to '/'. To use dot notation, pass delimiter='.' explicitly.
fix
Use unflatten(flat, delimiter='.') with dot-separated keys.
affects: >=0.2.0
gotchaThe library does not automatically handle integer keys for list indices. You must specify a 'splitter' that returns ints or parse manually.
fix
Example: from unflatten import split, unflatten; unflatten({'a.0.b': 1}, splitter=lambda s: [int(p) if p.isdigit() else p for p in split(s, '.')])
affects: all
deprecatedUsing 'None' as a value in the flat dict may cause unexpected behavior (treated as missing). This behavior is undocumented and may change.
fix
Avoid None values in input dict or handle separately.
affects: all
Errors
Common errors & fixes
AttributeError: module 'unflatten' has no attribute 'unflatten'
Trying to call unflatten.unflatten() after doing `import unflatten` instead of `from unflatten import unflatten`.
fix
Use: `from unflatten import unflatten`
KeyError: 'a.b.c'
Using default delimiter '/' but keys contain dots (or vice versa). Version 0.2.0 changed default delimiter to '/'.
fix
Specify delimiter: unflatten(flat, delimiter='.')
TypeError: unflatten() got an unexpected keyword argument 'splitter'
splitter argument is available only in version 0.2.0+. Older version does not support it.
fix
Upgrade to 0.2.0: pip install --upgrade unflatten
Upgrade
Version history
0.2.0latest on PyPI · released Sep 5, 2024
Audit
Dependencies

No dependency data recorded yet.

Agent activity
19 hits · last 30 days
node
14
Amazon
1
OpenAI (training)
1
Resources
unflatten — pip install unflatten · libregistry