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

1.3.0 serialization fails due to get_mro #118

Closed georgeharker closed 4 years ago

georgeharker commented 4 years ago

something changed in 1.3.0 and I think the usage of get_mro is to blame,

one of my classes fails to serialize with the error 'copy_with' not found.

It looks like get_mro() inside _get_complete_class_dict is returning typing types,

(<class 'typing._GenericAlias'>, <class 'typing._Final'>, <class 'object'>)

and the copy_with function on typing._GenericAlias finds it's way out as thing to be serialized as an attribute - which it isn't.

which is odd as the usage is like

get_mro(core.tracks.Pattern)

(so no typing wrappers involved).

get_origin(core.tracks.Pattern) is returning

typing.Pattern

which is what I imagine is wha's going awry. Given it looks like a typish bug I'll report over there too.

ramonhagenaars commented 4 years ago

This is indeed a bug in typish's get_origin, which will be resolved in its next release. Once available, please update typish to the latest version, that'll do the trick. jsons will soon follow with a dependency on that new version.

I'll close this one.