zerwes/hiyapyco

Wrong Recursive call on method _substmerge

reddart opened this issue · 8 comments

Inside method _substmerge (line 343, hiyapyco/init.py), the recursive call is wrongly written as self._deepmerge (line 374, hiyapyco/init.py). It's a quick fix plaguing this superb library.

Please fix. It's a quick one.

zerwes commented

Hello @reddart ; Thank you for the report. I'll have a look at it asap.

zerwes commented

related: #38

Thanks a lot @zerwes
Yes, same bug as in #38 . Wonder why it was never merged into main?

zerwes commented

merge was never done due to failing tests ...

zerwes commented

Hello @reddart ... is the fix in #64 what you expect?

Hello @reddart ... is the fix in #64 what you expect?

Same change needed in line 366 @zerwes

zerwes commented

yes ... but with

diff --git a/hiyapyco/__init__.py b/hiyapyco/__init__.py
index c319c9c..fa0637d 100644
--- a/hiyapyco/__init__.py
+++ b/hiyapyco/__init__.py
@@ -357,15 +357,15 @@ class HiYaPyCo:
 
         elif isinstance(a, dict):
             if isinstance(b, dict):
-                logger.debug('deepmerge: dict ... "%s" and "%s"' % (a, b,))
+                logger.debug('substmerge: dict ... "%s" and "%s"' % (a, b,))
                 for k in b:
                     if k in a:
                         logger.debug(
-                            'deepmerge dict: loop for key "%s": "%s" and "%s"' % (k, a[k], b[k],)
+                            'substmerge dict: loop for key "%s": "%s" and "%s"' % (k, a[k], b[k],)
                             )
-                        a[k] = self._deepmerge(a[k], b[k])
+                        a[k] = self._substmerge(a[k], b[k])
                     else:
-                        logger.debug('deepmerge dict: set key %s' % k)
+                        logger.debug('substmerge dict: set key %s' % k)
                         a[k] = b[k]
             elif isinstance(b, listTypes):
                 logger.debug('substmerge: dict <- list ... "%s" <- "%s"' % (a, b,))

the test is failing

...
start test /home/zerwes/git/hiyapyco/test/test_merge.py for hiyapyco 0.5.1 using python 3.11.2 (loglevel:WARNING)
Traceback (most recent call last):
  File "/home/zerwes/git/hiyapyco/test/test_merge.py", line 50, in <module>
    assert t == ['base1', 'base2', 'baseext1', 'baseext2']
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError
make: *** [Makefile:41: test] Error 1

as the substmerge is provided via a PR, I'll have to take a deeper look

zerwes commented

merged in #64