1def type_check(position):
2 def inner(*types):
3 def decorate(func):
4 def wrp(*args, **kwargs):
5 if position == "in":
6 for arg in args:
7 if not isinstance(arg, types):
8 expected_str = ", ".join(str(t) for t in types)
9 print(f"Invalid input arguments, expected {expected_str}!")
10 break
11 else:
12 result = func(*args, **kwargs)
13 if not isinstance(result, types):
14 expected_str = ", ".join(str(t) for t in types)
15 print(f"Invalid output value, expected {expected_str}!")
16 return result
17 return func(*args, **kwargs)
18 return wrp
19 return decorate
20 return inner
....
----------------------------------------------------------------------
Ran 4 tests in 0.004s
OK