You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have the following code that uses a forward reference per PEP484.
@dataclass_validate@dataclassclassDC4:
member1: str# member2 can be either a string or a DC4 instancemember2: Union[str, "DC4"]
deftest_forwardReference():
DC4("Hello", "World")
DC4("Hello", DC4("World", "Too"))
# This should raise a validation error but doesn'twithpytest.raises(TypeValidationError) ase:
DC4("Hello", 1)
At the moment I can set member2 to any value and no TypeValidationError is raised.
I suspect this is because the forward reference is not resolved by the dataclass library. If I print out the type of each field of DC4 I get the following:
Thanks for creating this great library~
I have the following code that uses a forward reference per PEP484.
At the moment I can set
member2
to any value and noTypeValidationError
is raised.I suspect this is because the forward reference is not resolved by the dataclass library. If I print out the type of each field of DC4 I get the following:
Is this a use case that you have considered?
The text was updated successfully, but these errors were encountered: