One function
TypeConflictStrategies in toumorokoshi/deepmerge
The author described this change as “fix: override_if_not_empty should not skip falsy primitives (0, False, 0.0) (#41)”. It counts as a record because the check below fails on the code as it stood at f4822dec8 and passes on d180db585, with nothing else changed between the two runs.
Projecttoumorokoshi/deepmerge
Fix saved2026-08-17
Sharing licenceMIT · LICENSE
Change size+11 −2
What the code was meant to do, written into the code itself as a docstring
contains the strategies provided for type conflicts.
The change
| 19 | 19 | def strategy_override_if_not_empty( | |
| 20 | 20 | config: deepmerge.merger.Merger, path: list, base: T1, nxt: T2 | |
| 21 | 21 | ) -> T1 | T2: | |
| 22 | - | """overrides the new object over the old object only if the new object is not empty or null""" | |
| 23 | - | return nxt if nxt else base | |
| 22 | + | """overrides the new object over the old object only if the new object is not empty or null. | |
| 23 | + | ||
| 24 | + | ``None`` is treated as null. Sized objects (``dict``, ``list``, ``set``, ``str``, …) are | |
| 25 | + | treated as empty when ``len(nxt) == 0``. All other values — including falsy primitives such | |
| 26 | + | as ``0``, ``0.0``, and ``False`` — are considered non-empty and will override *base*. | |
| 27 | + | """ | |
| 28 | + | if nxt is None: | |
| 29 | + | return base | |
| 30 | + | if isinstance(nxt, Sized) and len(nxt) == 0: | |
| 31 | + | return base | |
| 32 | + | return nxt |
The check that tells the two apart
fail→pass·deepmerge/tests/strategy/test_type_conflict.py::test_merge_if_not_empty_falsy[zero
Check file deepmerge/tests/strategy/test_type_conflict.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 itf4822dec8ce4aec26fa142777ae949f543e341ad
Broken version dated2026-06-22
Moduledeepmerge.strategy.type_conflict
Units changedTypeConflictStrategies
Fingerprint93c567091761c62d
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
- 2023-12-18Merger