PyContracts is a Python package that allows to declare constraints on function parameters and return values. Contracts can be specified using Python3 annotations, or inside a docstring. PyContracts supports a basic type system, variables binding, arithmetic constraints, and has several specialized contracts and an extension API.
Hello,
Starting from a very simple integer-related contract:
int,(-1 | 1)
I've tried to write the same kind of contract, but for string values, e.g.:
string,(a | b)
Unfortunately, that syntax is not accepted by PyContracts.
It would also be nice to introduce regexp in contracts, to be matched against string values.
Thanks.