Repository: ramonhagenaars/jsons

Issue:
fork_inst not being passed along to element deserializer in default list deserializer
https://github.com/ramonhagenaars/jsons/blob/a5150cdd2704e83fe5f8798822a1c901b54dcb1c/jsons/deserializers/default_list.py#L59

I'm not sure if this is intentional or not.

I've registered my deserializers in a fork_inst, but they are not called in certain circumstances.

I tracked the issue down to the linked line in the default_list_deserializer.

My guess is that the kwargs argument should be extended with the fork_inst parameter, before calling the element deserializer.

For now I will check if my issue can be solved, bei either overwriting default_list_deserializer or by not using a fork_inst at all.

Comments:

Patch:
diff --git a/.github/workflows/pythonapp.yml b/.github/workflows/pythonapp.yml
index 5aadfc3..c0ee5c0 100644
--- a/.github/workflows/pythonapp.yml
+++ b/.github/workflows/pythonapp.yml
@@ -17,14 +17,14 @@ jobs:
         ]
         os: [
             ubuntu-latest,
-#            macOS-latest,  FIXME: seems to not work at the moment.
+            macOS-latest,
             windows-latest
         ]
     name: Python ${{ matrix.python-version }} on ${{ matrix.os }}
     steps:
       - uses: actions/checkout@master
       - name: Setup python
-        uses: actions/setup-python@v1
+        uses: actions/setup-python@v3
         with:
           python-version: ${{ matrix.python-version }}
           architecture: x64
diff --git a/docs/_templates/sidebarintro.html b/docs/_templates/sidebarintro.html
index 155b876..b78a06e 100644
--- a/docs/_templates/sidebarintro.html
+++ b/docs/_templates/sidebarintro.html
@@ -14,7 +14,7 @@
 <h3>Links</h3>
 <ul>
     <li>
-        <a href="https://ghbtns.com/github-btn.html?user=ramonhagenaars&repo=jsons&type=watch&count=true&size=large" allowtransparency="true" frameborder="0" scrolling="0" width="200px" height="35px">jsons - Github</a>
+        <a href="https://github.com/ramonhagenaars/jsons/" allowtransparency="true" frameborder="0" scrolling="0" width="200px" height="35px">jsons - Github</a>
     </li>
     <li>
         <a href="https://pypi.org/project/jsons/">jsons - PyPi</a>
diff --git a/jsons/deserializers/default_list.py b/jsons/deserializers/default_list.py
index f64aeda..6f3a880 100644
--- a/jsons/deserializers/default_list.py
+++ b/jsons/deserializers/default_list.py
@@ -56,7 +56,7 @@ def _do_load(
     result = []
     for index, elem in enumerate(obj):
         try:
-            result.append(load(elem, cls=cls, tasks=1, **kwargs))
+            result.append(load(elem, cls=cls, tasks=1, fork_inst=fork_inst, **kwargs))
         except DeserializationError as err:
             new_msg = ('Could not deserialize element at index %s. %s' %
                        (index, err.message))


Test patch:
diff --git a/tests/test_list.py b/tests/test_list.py
index a5a7286..4dcceb3 100644
--- a/tests/test_list.py
+++ b/tests/test_list.py
@@ -184,3 +184,17 @@ class TestList(TestCase):
 
             self.assertIn('500', warn_msg)
             self.assertEqual(999, len(loaded))
+
+    def test_propagation_of_fork_inst(self):
+        class C:
+            def __init__(self, x: int):
+                self.x = x
+
+        def c_deserializer(obj, *_, **__) -> C:
+            return C(obj['x'] * 2)
+
+        fork = jsons.fork(name='fork_inst_propagation')
+        jsons.set_deserializer(c_deserializer, C, fork_inst=fork)
+        cs = jsons.loads('[{"x":2},{"x":3}]', List[C], fork_inst=fork)
+        self.assertEqual(4, cs[0].x)
+        self.assertEqual(6, cs[1].x)