-
-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Investigate support for recursive Union types #206
Comments
Hi @JWCS
The type statement is not yet supported, but this is a good improvement that would be good to include in the next release. It should be trivial.
Recursion is a problem here. I have not encountered such a case yet, so it has not been tested. It will take more time to figure out if this case can be supported. I'm curious in which real case such a broad recursive type is needed. Could you tell me in more detail about how you are going to use this JSON type? |
Thanks for the response. I actually wasn't sure if I was being oblivious in the documentation, and missing this recursive case. I know there's support for custom types... but compared to the lazy solution (below), I was hoping it was me. My real world use case is for dealing with abstract customer json payloads, and validating no (structural) corruption in transmission. Alternatively, what I am currently doing (the show must move on), is just |
Description
In the past, I've used the below JSON type definitions, which have worked well with both static and runtime type checkers (mypy (except the new one, wip) and beartype).
I had a message type that included an arbitrary json blob as a field. Attempting to serialize that with mashumaro led to an error.
I'm not entirely sure if this recursive functionality is supported by mashumaro, due to pre-compilation, only that the underlying types themselves are.
If there's a better workaround, I apologies if I missed the documentation.
What I Did
I tried to use both the "new" 3.12 type keyword definition of JSON, and the "old" recursive style (avoiding
from __future__ import annotations
).The text was updated successfully, but these errors were encountered: