We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
generic
Hi, thanks for the great library!
Assuming this class hierarchy
import msgspec from msgspec import Struct class SystemsStatus[T: msgspec.Struct](Struct, tag=True): ... class SystemsStatusInitial[T: msgspec.Struct](SystemsStatus[T]): nodes: list[T] class SystemsRemoved[T: msgspec.Struct](SystemsStatus[T]): ids: list[int] class SystemsUpdated[T: msgspec.Struct](SystemsStatus[T]): nodes: list[T] def get_union[T: msgspec.Struct](t: type[T]) -> type[SystemsStatus[T]]: return SystemsRemoved[t] | SystemsStatusInitial[t] | SystemsUpdated[t] DECODER = msgspec.json.Decoder(get_union(SomeDTO))
Is this the prefered way to create a decoder or I can do something like this
DECODER = msgspec.json.Decoder(SystemsStatus[SomeDTO])
Which failed decoding one of the inherited classes data.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Question
Hi, thanks for the great library!
Assuming this class hierarchy
Is this the prefered way to create a decoder or I can do something like this
Which failed decoding one of the inherited classes data.
The text was updated successfully, but these errors were encountered: