-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Labels
Description
Should we support contracts?
It would be straightforward to support contracts by supporting custom callables in type signatures. For example:
@params(a=int, b=lambda b: b != 0)
def div(a, b):
return a / b
However, I find that syntax clunky (for contracts), compared to something like:
@contract
def div(a, b):
return a / b
@div.requires
def div(a, b):
assert isinstance(a, int)
assert b != 0
But this being typedecorator, not a full-blown contracts library, I'm hesitant to grow it in that direction (unless there's popular demand).
Reactions are currently unavailable