Skip to content

Commit 02b8610

Browse files
committed
v1.3.2 - add py.typed and update typings, close #2
1 parent 3476e25 commit 02b8610

File tree

7 files changed

+21
-13
lines changed

7 files changed

+21
-13
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ $ pip install mergedeep
2020
## Usage
2121

2222
```text
23-
merge(destination: Map[KT, VT], *sources: Map[KT, VT], strategy: Strategy = Strategy.REPLACE) -> Map[KT, VT]
23+
merge(destination: Dict, *sources: Dict, strategy: Strategy = Strategy.REPLACE) -> Dict
2424
```
2525

2626
Deep merge without mutating the source dicts.

docs/source/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ $ pip install mergedeep
3232
## Usage
3333

3434
```text
35-
merge(destination: Map[KT, VT], *sources: Map[KT, VT], strategy: Strategy = Strategy.REPLACE) -> Map[KT, VT]
35+
merge(destination: Dict, *sources: Dict, strategy: Strategy = Strategy.REPLACE) -> Dict
3636
```
3737

3838
Deep merge without mutating the source dicts.

example.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from mergedeep import merge
2+
3+
a = {"keyA": 1}
4+
b = {"keyB": {"sub1": 10}}
5+
c = {"keyB": {"sub2": 20}}
6+
7+
merged = merge({}, a, b, c)
8+
9+
print(merged)
10+
# {"keyA": 1, "keyB": {"sub1": 10, "sub2": 20}}

mergedeep/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "1.3.1"
1+
__version__ = "1.3.2"
22

33
from mergedeep.mergedeep import merge, Strategy
44

mergedeep/mergedeep.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@
33
from copy import deepcopy
44
from enum import Enum
55
from functools import reduce, partial
6-
from typing import TypeVar, MutableMapping as Map
7-
8-
KT = TypeVar("KT")
9-
VT = TypeVar("VT")
6+
from typing import Dict
107

118

129
class Strategy(Enum):
@@ -74,10 +71,10 @@ def _is_recursive_merge(a, b) -> bool:
7471
return both_mapping and not both_counter
7572

7673

77-
def _deepmerge(dst: Map[KT, VT], src: Map[KT, VT], strategy: Strategy = Strategy.REPLACE):
74+
def _deepmerge(dst: Dict, src: Dict, strategy: Strategy = Strategy.REPLACE):
7875
"""
79-
:param dst: Map[KT, VT]:
80-
:param src: Map[KT, VT]:
76+
:param dst: Dict:
77+
:param src: Dict:
8178
"""
8279
for key in src:
8380
if key in dst:
@@ -95,12 +92,12 @@ def _deepmerge(dst: Map[KT, VT], src: Map[KT, VT], strategy: Strategy = Strategy
9592
return dst
9693

9794

98-
def merge(destination: Map[KT, VT], *sources: Map[KT, VT], strategy: Strategy = Strategy.REPLACE) -> Map[KT, VT]:
95+
def merge(destination: Dict, *sources: Dict, strategy: Strategy = Strategy.REPLACE) -> Dict:
9996
"""
10097
A deep merge function for 🐍.
10198
102-
:param destination: Map[KT, VT]:
103-
:param *sources: Map[KT, VT]:
99+
:param destination: Dict:
100+
:param *sources: Dict:
104101
:param strategy: Strategy (Default: Strategy.REPLACE):
105102
"""
106103
return reduce(partial(_deepmerge, strategy=strategy), sources, destination)

py.typed

Whitespace-only changes.

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ def open_local(paths, mode="r", encoding="utf8"):
1919
url="https://github.com/clarketm/mergedeep",
2020
python_requires=">=3.6",
2121
packages=setuptools.find_packages(),
22+
package_data={"mergedeep": ["py.typed"]},
2223
classifiers=(
2324
"Programming Language :: Python :: 3",
2425
"Programming Language :: Python :: 3.6",

0 commit comments

Comments
 (0)