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
When using the Optional type hint, I can no longer convert from a json string into the data class.
Optional
The following code will trow
TypeError: A.c was defined to be any of: (<class '__main__.B'>, <class 'NoneType'>) but was found to be <class 'dict'> instead
from typing import List, Optional from dataclasses import dataclass from typed_json_dataclass import TypedJsonMixin @dataclass class B(TypedJsonMixin): a: float = 0.0 b: float = 0.0 c: float = 0.0 @dataclass class A(TypedJsonMixin): a: Optional[int] = None b: Optional[str] = None c: Optional[B] = None b = B(1.0, 1.0, 1.0) a = A(1, "a", b) c = A.from_json(a.to_json())
Create a data class of type A
A
Does not create the dataclass of type A from the json and trows an error.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Subject of the issue
When using the
Optional
type hint, I can no longer convert from a json string into the data class.Steps to reproduce
The following code will trow
Expected behaviour
Create a data class of type
A
Actual behaviour
Does not create the dataclass of type
A
from the json and trows an error.The text was updated successfully, but these errors were encountered: