From 71cd606fadfa6e07e556fc81203adee10005d1f8 Mon Sep 17 00:00:00 2001 From: Romain Dorgueil Date: Mon, 16 Jul 2018 12:12:15 +0200 Subject: [PATCH] experiment: try to autocast when possible --- bonobo/execution/contexts/node.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/bonobo/execution/contexts/node.py b/bonobo/execution/contexts/node.py index 07cbf16..a447261 100644 --- a/bonobo/execution/contexts/node.py +++ b/bonobo/execution/contexts/node.py @@ -286,11 +286,17 @@ class NodeExecutionContext(BaseContext, WithStatistics): if self._input_type is None: self._input_type = type(input_bag) elif type(input_bag) is not self._input_type: - raise UnrecoverableTypeError( - 'Input type changed between calls to {!r}.\nGot {!r} which is not of type {!r}.'.format( - self.wrapped, input_bag, self._input_type - ) - ) + try: + if type(self._input_type) == tuple: + input_bag = self._input_type(tuple) + else: + input_bag = self._input_type(*input_bag) + except Exception as exc: + raise UnrecoverableTypeError( + 'Input type changed to incompatible type between calls to {!r}.\nGot {!r} which is not of type {!r}.'.format( + self.wrapped, input_bag, self._input_type + ) + ) from exc # Store or check input length, which is a soft fallback in case we're just using tuples if self._input_length is None: