Deep merge dictionaries safely with conflict resolution
Project description
philiprehberger-dict-merge
Deep merge dictionaries safely with conflict resolution.
Installation
pip install philiprehberger-dict-merge
Usage
from philiprehberger_dict_merge import merge, Strategy
base = {"db": {"host": "localhost", "port": 5432}, "debug": False}
override = {"db": {"port": 3306, "name": "mydb"}, "debug": True}
merge(base, override)
# {"db": {"host": "localhost", "port": 3306, "name": "mydb"}, "debug": True}
# Multiple dicts
merge(defaults, config_file, env_overrides)
# Keep first value on conflict
merge(a, b, strategy=Strategy.KEEP_FIRST)
# Append lists instead of replacing
merge(a, b, list_strategy="append")
API
merge(*dicts, strategy=Strategy.REPLACE, list_strategy="replace")— Deep mergeStrategy.REPLACE— Later values win (default)Strategy.KEEP_FIRST— Earlier values winStrategy.ERROR— Raise on conflict- List strategies:
"replace","append","unique","concat"
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file philiprehberger_dict_merge-0.1.0.tar.gz.
File metadata
- Download URL: philiprehberger_dict_merge-0.1.0.tar.gz
- Upload date:
- Size: 4.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9b50f0f11c92f7f6e864d723021abb12ae60da6b8156172ebbe31d1aa85d937a
|
|
| MD5 |
d1d2423a9e2362d8fa641f020927fdab
|
|
| BLAKE2b-256 |
99e19074ffb01fa4c87abbafad71ff6626c7fb6f9e13fcfc5ff8493be9db26e8
|
File details
Details for the file philiprehberger_dict_merge-0.1.0-py3-none-any.whl.
File metadata
- Download URL: philiprehberger_dict_merge-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4a3e823aac42d11de73f0a6bf5c8434d490b6e51156e084205455964fdda0c9a
|
|
| MD5 |
715a49ba315f374e024ab3156adcdd18
|
|
| BLAKE2b-256 |
3032564fd79849c70c47ed20518624138e41c5f5e04e29092671dd8789451af4
|