Skip to content

Commit fe997ab

Browse files
committed
v1.3.3 - refine types and docstrings
1 parent 02b8610 commit fe997ab

File tree

6 files changed

+14
-16
lines changed

6 files changed

+14
-16
lines changed

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,11 @@ test-setup:
2020
@pyenv install -s 3.6.10
2121
@pyenv install -s 3.7.7
2222
@pyenv install -s 3.8.2
23+
@pyenv install -s 3.9.1
2324

2425
.PHONY: test
2526
test: test-setup
26-
@pyenv local 3.6.10 3.7.7 3.8.2
27+
@pyenv local 3.6.10 3.7.7 3.8.2 3.9.1
2728
@$(PYTHON) -m tox
2829

2930
.PHONY: clean

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: Dict, *sources: Dict, strategy: Strategy = Strategy.REPLACE) -> Dict
23+
merge(destination: MutableMapping, *sources: Mapping, strategy: Strategy = Strategy.REPLACE) -> Mapping
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: Dict, *sources: Dict, strategy: Strategy = Strategy.REPLACE) -> Dict
35+
merge(destination: MutableMapping, *sources: Mapping, strategy: Strategy = Strategy.REPLACE) -> Mapping
3636
```
3737

3838
Deep merge without mutating the source dicts.

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.2"
1+
__version__ = "1.3.3"
22

33
from mergedeep.mergedeep import merge, Strategy
44

mergedeep/mergedeep.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from copy import deepcopy
44
from enum import Enum
55
from functools import reduce, partial
6-
from typing import Dict
6+
from typing import MutableMapping
77

88

99
class Strategy(Enum):
@@ -65,17 +65,13 @@ def _handle_merge_typesafe(destination, source, key, strategy):
6565
}
6666

6767

68-
def _is_recursive_merge(a, b) -> bool:
68+
def _is_recursive_merge(a, b):
6969
both_mapping = isinstance(a, Mapping) and isinstance(b, Mapping)
7070
both_counter = isinstance(a, Counter) and isinstance(b, Counter)
7171
return both_mapping and not both_counter
7272

7373

74-
def _deepmerge(dst: Dict, src: Dict, strategy: Strategy = Strategy.REPLACE):
75-
"""
76-
:param dst: Dict:
77-
:param src: Dict:
78-
"""
74+
def _deepmerge(dst, src, strategy=Strategy.REPLACE):
7975
for key in src:
8076
if key in dst:
8177
if _is_recursive_merge(dst[key], src[key]):
@@ -92,12 +88,13 @@ def _deepmerge(dst: Dict, src: Dict, strategy: Strategy = Strategy.REPLACE):
9288
return dst
9389

9490

95-
def merge(destination: Dict, *sources: Dict, strategy: Strategy = Strategy.REPLACE) -> Dict:
91+
def merge(destination: MutableMapping, *sources: Mapping, strategy: Strategy = Strategy.REPLACE) -> MutableMapping:
9692
"""
9793
A deep merge function for 🐍.
9894
99-
:param destination: Dict:
100-
:param *sources: Dict:
101-
:param strategy: Strategy (Default: Strategy.REPLACE):
95+
:param destination: The destination mapping.
96+
:param sources: The source mappings.
97+
:param strategy: The merge strategy.
98+
:return:
10299
"""
103100
return reduce(partial(_deepmerge, strategy=strategy), sources, destination)

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tox]
2-
envlist = py36,py37,py38
2+
envlist = py36,py37,py38,py39
33

44
[testenv]
55
deps = pytest

0 commit comments

Comments
 (0)