anikolaienko / py-automapper

Python object auto mapper
https://anikolaienko.github.io/py-automapper/
MIT License
56 stars 10 forks source link

Dict mapping throws Exception #4

Closed damjan-icentic closed 2 years ago

damjan-icentic commented 2 years ago

If source objects contains dict attribute like enums = { "enmu0": "some value", "enum1": "some other value" } automapper throws ValueError: too many values to unpack (expected 2) I guess the problem is this part of code: if is_sequence(obj): if isinstance(obj, dict): result = { k: self._map_subobject( v, _visited_stack, skip_none_values=skip_none_values ) for k, v in obj } I think it should be for k, v in obj.items()

anikolaienko commented 2 years ago

Oh, that's interesting, let me take a look at it this week and I'll try to fix it. Or you are welcome to submit a Pull Request with changes :)

anikolaienko commented 2 years ago

@damjan-icentic Thank you so much for pointing out the issue. It is fixed in the latest published release. Here is the test case: https://github.com/anikolaienko/py-automapper/blob/main/tests/test_automapper_dict_field.py