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.
In [32]: @contract(a='number')
...: def foo(a):
...: return a
In [33]: foo(9999999L)
. . . . . . . .
.................. # long error outptut here
------- (end clauses) -------
checking: float|int|uint for value: Instance of <type 'long'>: 9999999L
checking: $(float|int|uint) for value: Instance of <type 'long'>: 9999999L
checking: number for value: Instance of <type 'long'>: 9999999L
Variables bound in inner context: