Apply type checks at run time for all outputs
Static type checks help to discover type inconsistencies before run time. But different Python packages that are used in the interpreter can return values of incorrect types at run time. For example this line from the tests:
assert next(v for v in var_objs if v.name == 'res_1').value
should better be
assert next(v for v in var_objs if v.name == 'res_1').value is True
because the value can be of any type whose truthiness evaluates to True
. But if we do this strict assertion then the test fails. The truthiness of the returned value is True
but the type is numpy.bool_
and not Python bool
type and therefore they are different objects. To fix this, the type must be detected and cast to Python bool
type using the item()
method. These type conversions can be inserted as a decorator to the value
property functions in the case of immediate execution interpreter and the func
property functions in the case of deferred execution interpreter. Similar casting is done here but this is only used in the workflow executor. The run-time type checker can be integrated in the same decorator but also in an independent function.