pyguardian is a type-checker for method parameters. Methods are type-checked at runtime via the guard
decorator:
from pyguardian import guard
@guard(int, int)
def add(a, b):
return a+b
# Successful call
>>> add(1,2)
3
# Unsccessful call ("2" is not an integer!)
>>> add(1,"2")
InvalidArgumentTypeError: 'add' expects value of type 'int' for parameter 'b' but got 'str'
pip install pyguardian
See DOCUMENTATION.md
pyguardian is licensed under the MIT License.