Hello
I’ve found this great package today, which allows you to set some constraints on your function parameters.
https://pypi.org/project/PyContracts/
Long story short, you can use the contracts like this:
@contract(a='int,>0', b='list[N],N>0', returns='list[N]') def my_function(a, b): ...
or like this:
@contract def my_function(a : 'int,>0', b : 'list[N],N>0') -> 'list[N]': # Requires b to be a nonempty list, and the return # value to have the same length. ...
I’m loving this!