Open wikiped opened 1 year ago
I too require this feature for the following data type:
class Ok(Generic[A]):
def __init__(self, value: A):
self.value = value
def to_json(self) -> JSON:
return {"ok": self.value}
def __bool__(self):
return True
class Err(Generic[A]):
def __init__(self, value: A):
self.value = value
def to_json(self) -> JSON:
return {"err": self.value}
def __bool__(self):
return False
Result = Ok[A] | Err[B]
Description
Suppose that an
int
field needs to be bound to some intervals:As the docs state:
the following will then expectedly fail:
Please consider lifting this restriction.