AndreaCensi / contracts

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.
http://andreacensi.github.io/contracts/
Other
398 stars 62 forks source link

Support for parametrized types annotations in Python3 (e.g. List[int]) #63

Open bruno314 opened 6 years ago

bruno314 commented 6 years ago

Hi, I have example

@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?

arxell commented 6 years ago

+1