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.
@contract
def double(x:List[int]) -> List[int]:
return list(map(lambda x:x*2, x))
double([1.245]) # doesn't complain about type problem
double(False) #complains about type problem (correctly)
that currently doesn't work but it should (and I believe it's already implemented because same functionality works using contracts-native string annotation). Is there any plan to support fully Python 3 types?
Hi, I have example
that currently doesn't work but it should (and I believe it's already implemented because same functionality works using contracts-native string annotation). Is there any plan to support fully Python 3 types?