From 0788951ba49103150e4118806107ab20ec012bcd Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Fri, 29 Mar 2024 22:20:36 -0300 Subject: [PATCH] Refactor extract_union_types_from_generic_alias function to exclude specific types --- .../base/langflow/interface/custom/code_parser/utils.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/backend/base/langflow/interface/custom/code_parser/utils.py b/src/backend/base/langflow/interface/custom/code_parser/utils.py index d73a109a6..0f97b4c7b 100644 --- a/src/backend/base/langflow/interface/custom/code_parser/utils.py +++ b/src/backend/base/langflow/interface/custom/code_parser/utils.py @@ -36,5 +36,11 @@ def extract_union_types_from_generic_alias(return_type: GenericAlias) -> list: Extracts the inner type from a type hint that is a Union. """ if isinstance(return_type, list): - return [_inner_arg for _type in return_type for _inner_arg in _type.__args__] + return [ + _inner_arg + for _type in return_type + for _inner_arg in _type.__args__ + if _inner_arg not in set((Any, type(None), type(Any))) + ] + return list(return_type.__args__)