value_generator = lambda : 5
assert isinstance(value_generator, ReturnValueGenerator)Return value generators
Create the appropriate return values
Once a matching signature was found, a return value generator will be used to construct the appropriate return value. In the simplest case, this might just be returning a constant value. However, the return value could be an arbitrary function evaluation and should have access to the exact arguments that were passed.
ReturnValueGenerator
ReturnValueGenerator (*args, **kwargs)
Construct a return value, potentially depended on the exact arguments used to call the function in the first place.
The most flexible way to implement a ReturnValueGenerator is to use a lambda:
A ReturnValueGenerator that accesses the original arguments:
arg_value_generator = lambda a,_: a+1
assert isinstance(value_generator, ReturnValueGenerator)