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
from dataclasses import dataclass
from typing import Literal
from dataclass_type_validator import dataclass_validate
@dataclass_validate
@dataclass
class ExampleClass:
check: Literal["success", "failure"] | None = None # Should be "success" or "failure"
a = ExampleClass("success")
b = ExampleClass("failure")
c = ExampleClass(None)
d = ExampleClass("invalid") # This passes validation even though it shouldn't
I tried strict = True, but that gives the following error:
RuntimeError: Unknown type of typing.Optional[typing.Literal['success', 'failure']] (_name = Optional)
The text was updated successfully, but these errors were encountered:
Minimum working example:
I tried
strict = True
, but that gives the following error:The text was updated successfully, but these errors were encountered: