From a542337a831e46b555fe093e9b7a2a900dfff7a0 Mon Sep 17 00:00:00 2001 From: Pierre Chapuis Date: Thu, 19 Sep 2024 15:03:37 +0200 Subject: [PATCH] fix typing see https://github.com/microsoft/pyright/issues/9025 --- src/refiners/fluxion/layers/chain.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/refiners/fluxion/layers/chain.py b/src/refiners/fluxion/layers/chain.py index f0331a7..0cb5f12 100644 --- a/src/refiners/fluxion/layers/chain.py +++ b/src/refiners/fluxion/layers/chain.py @@ -243,11 +243,15 @@ class Chain(ContextModule): raise ChainError(message) from None def forward(self, *args: Any) -> Any: - result: tuple[Any] | Any = None + result: Any = None intermediate_args: tuple[Any, ...] = args for name, layer in self._modules.items(): result = self._call_layer(layer, name, *intermediate_args) - intermediate_args = (result,) if not isinstance(result, tuple) else result + if isinstance(result, tuple): + result = cast(tuple[Any], result) + intermediate_args = result + else: + intermediate_args = (result,) self._reset_context() return result