Skip to content

Commit a970275

Browse files
committed
Reduce complexity found by Ruff
Simplify the case for lists and tuples
1 parent 8e3bf68 commit a970275

1 file changed

Lines changed: 4 additions & 7 deletions

File tree

src/docbuild/config/merge.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from collections.abc import Mapping
44
from copy import deepcopy
5-
from typing import Any, cast
5+
from typing import Any
66

77

88
def deep_merge(*dcts: Mapping[str, Any]) -> dict[str, Any]:
@@ -53,13 +53,10 @@ def deep_merge(*dcts: Mapping[str, Any]) -> dict[str, Any]:
5353
stack.append((existing, value))
5454

5555
# Lists / tuples → concatenate
56-
elif isinstance(existing, (list, tuple)) and isinstance(
57-
value, (list, tuple)
56+
elif (isinstance(existing, list) and isinstance(value, list)) or (
57+
isinstance(existing, tuple) and isinstance(value, tuple)
5858
):
59-
if isinstance(existing, list):
60-
dest[key] = existing + list(deepcopy(value))
61-
else:
62-
dest[key] = tuple(existing) + tuple(deepcopy(value))
59+
dest[key] = existing + deepcopy(value) # type: ignore[operator]
6360

6461
# Sets → union
6562
elif isinstance(existing, set) and isinstance(value, set):

0 commit comments

Comments
 (0)