ramonhagenaars / jsons

🐍 A Python lib for (de)serializing Python objects to/from JSON
https://jsons.readthedocs.io
MIT License
289 stars 41 forks source link

Object deserialization is broken for subtypes without full constructors #128

Closed rupert-madden-abbott closed 3 years ago

rupert-madden-abbott commented 3 years ago

The problem is that _set_remaining_attrs uses __annotations__ to set any attributes that are not present in the constructor.

This works fine for classes that just inherit from object or for attributes declared directly on a subclass. However, it doesn't retrieve annotations from any parent class.

The problem is compounded because the failure is completely silent.

Instead get_type_hints should be used which will return hints from parents also.

ramonhagenaars commented 3 years ago

Thanks @rupert-madden-abbott . This will be fixed in version 1.4.1.