This module contains some generally useful function and method decorators.
Decorator for functions: decorates a function with parameter and return types. Type checking is performed dynamically.
Typical use:
@sig([type_1, ..., type_n], type_ret)
def func(param_1, ..., param_n):
...
return ...
When invoking func(arg_1, ..., arg_n), this decorator checks that arg_i is an instance of type_i, and that the returned value is an instance of type_ret.
Parameters: |
|
---|---|
Returns: | A “typecheck” function which accepts as parameter a function f and returns the decorated function. |
Return type: | function decorator (function -> function) |
Decorator for methods: decorates a method with parameter and return types. Type checking is performed dynamically.
This is just like the sig decorator, but ignores the first argument.
Typical use:
@msig([type_1, ..., type_n], type_ret)
def meth(self, param_1, ..., param_n):
...
return ...
When invoking func(arg_1, ..., arg_n), this decorator checks that arg_i is an instance of type_i, and that the returned value is an instance of type_ret.
Parameters: |
|
---|---|
Returns: | A “typecheck” function which accepts as parameter a function f and returns the decorated function. |
Return type: | method decorator (method -> method) |