diff --git a/mathics/core/builtin.py b/mathics/core/builtin.py index 4cc6ae503..31d5ad352 100644 --- a/mathics/core/builtin.py +++ b/mathics/core/builtin.py @@ -653,7 +653,7 @@ def get_mpmath_function(self, args): def eval(self, z, evaluation: Evaluation): "%(name)s[z__]" - args = cast(Sequence[Number], numerify(z, evaluation).get_sequence()) + args = numerify(z, evaluation).get_sequence() # if no arguments are inexact attempt to use sympy if all(not x.is_inexact() for x in args): @@ -668,6 +668,8 @@ def eval(self, z, evaluation: Evaluation): if not all(isinstance(arg, Number) for arg in args): return + # mypy isn't yet smart enough to recognise that we can only reach this point if all args are Numbers + args = cast(Sequence[Number], args) mpmath_function = self.get_mpmath_function(tuple(args)) if mpmath_function is None: @@ -680,7 +682,9 @@ def eval(self, z, evaluation: Evaluation): d = dps(prec) args = tuple([arg.round(d) for arg in args]) - return eval_mpmath_function(mpmath_function, *args, prec=prec) + return eval_mpmath_function( + mpmath_function, *cast(Sequence[Number], args), prec=prec + ) class MPMathMultiFunction(MPMathFunction):