Switch from using eval to use the simpleeval library
Currently, the HeterodyneDAGRunner object has an eval
method that tries to safely evaluate inputs from a configuration file. It tries using ast.literal_eval
, and if that fails (which is does for things like "1/60"
), it tries to assess whether the string is safe to just use eval
and then uses that. However, there's a package called simpleval, that should safely evaluate things without the need for the try...except...
block.
It could be used with:
from simpleeval import EvalWithCompoundTypes
expression = "[1, 1./60.]"
seval = EvalWithCompoundTypes()
seval.eval(expression)