Skip to content

Commit

Permalink
Add deepmerge util
Browse files Browse the repository at this point in the history
  • Loading branch information
Setsugennoao committed Jul 15, 2024
1 parent 1d8ab21 commit 5b85b4e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions stgpytools/functions/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from .funcs import * # noqa: F401, F403
from .normalize import * # noqa: F401, F403
from .other import * # noqa: F401, F403
18 changes: 18 additions & 0 deletions stgpytools/functions/other.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from __future__ import annotations

from typing import Any

__all__ = [
'deepmerge'
]


def deepmerge(source: dict[Any, Any], destination: dict[Any, Any]) -> dict[Any, Any]:
for key, value in source.items():
if isinstance(value, dict):
node = destination.setdefault(key, {})
deepmerge(value, node)
else:
destination[key] = value

return destination

0 comments on commit 5b85b4e

Please sign in to comment.