One function

Merger in toumorokoshi/deepmerge

The author described this change as fix: make predefined merge strategies work with primitive collections subtypes (#25). It counts as a record because the check below fails on the code as it stood at 48cc8cbfc and passes on 98ec8c11a, with nothing else changed between the two runs.

Fix saved2023-12-18
Sharing licenceMIT · LICENSE
Change size+3 3

What the code was meant to do, written into the code itself as a docstring

:param type_strategies, List[Tuple]: a list of (Type, Strategy) pairs that should be used against incoming types. For example: (dict, "override").

The change

2929 return self._type_conflict_strategy(self, *args)
3030
3131 def value_strategy(self, path, base, nxt):
32- if not (isinstance(base, type(nxt)) or isinstance(nxt, type(base))):
33- return self.type_conflict_strategy(path, base, nxt)
3432 for typ, strategy in self._type_strategies:
35- if isinstance(nxt, typ):
33+ if isinstance(base, typ) and isinstance(nxt, typ):
3634 return strategy(self, path, base, nxt)
35+ if not (isinstance(base, type(nxt)) or isinstance(nxt, type(base))):
36+ return self.type_conflict_strategy(path, base, nxt)
3737 return self._fallback_strategy(self, path, base, nxt)

The check that tells the two apart

failpass·deepmerge/tests/test_full.py::test_subtypes

Check file deepmerge/tests/test_full.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.

Origin and history

The code before it48cc8cbfc45dce7a5cacddcb835d938786100f2f
Broken version dated2023-12-18
Moduledeepmerge.merger
Units changedMerger
Fingerprint2e8c626b03444801
Checked2026-08-18 by goldset/0.1

Every field above is generated by our program. None of it is written by hand.

Other bugs found in toumorokoshi/deepmerge