python-type-valid
Python type validation decorator, validates input and output types
Installation
pip install type-valid
Usage
from type_valid import type_valid
@type_valid
def hello(name: str) -> str:
return name
#valid
hello("Bob")
#invalid
hello(1)
@type_valid
def user(name: str, age: int, salary: float) -> str:
return name+str(age)+str(salary)
#valid
user(name="Bob", age=25, salary=1000.00)
Raises TypeError
TypeError: in method 'hello', Argument 'name' is not of type <class 'str'>, received <class 'int'>
Todo:
- Validate input DONE
- Validate Output DONE
- Validate input **kwargs ?
- Validate mandatory **kwargs ?
- Multiple types ?
Types examples
str ""
int 4
float 10.5
list []
tuple ()
...