msgspec
msgspec copied to clipboard
Draft: feat: allow converting subclasses of tagged structs
Hi,
This is a very rough draft, opening to see if @jcrist will be open for this feature/approach.
It addresses #656 and my own #541 - allowing to decode data representing a tagged struct subclass in place of the super class.
This feature prevents me from switching to msgspec in my ast library, but should be generally very usable for any tree-like structure/messages.
As of time of writing, in order for this PR to be complete, at least the following has to be handled:
- [ ] Wire the new
allow_tagged_struct_subtypeskwarg into json, msg pack decoders - [ ] Properly handle type node / struct info caching. As of now, cache doesn't account for
allow_tagged_struct_subtypes, so it will not honor the flag after decoder (type node) is cached for the first time - [ ] Add more tests