From 1dbe776e6adf5045943e409791a7d146b9a887a3 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Tue, 22 Aug 2023 16:11:47 -0300 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(utils.py):=20add=20function=20?= =?UTF-8?q?extract=5Finner=5Ftype=20to=20extract=20the=20inner=20type=20fr?= =?UTF-8?q?om=20a=20type=20hint=20that=20is=20a=20list?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/langflow/interface/custom/utils.py | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 src/backend/langflow/interface/custom/utils.py diff --git a/src/backend/langflow/interface/custom/utils.py b/src/backend/langflow/interface/custom/utils.py new file mode 100644 index 000000000..99b0d4bc6 --- /dev/null +++ b/src/backend/langflow/interface/custom/utils.py @@ -0,0 +1,10 @@ +import re + + +def extract_inner_type(return_type: str) -> str: + """ + Extracts the inner type from a type hint that is a list. + """ + if match := re.match(r"list\[(.*)\]", return_type, re.IGNORECASE): + return match[1] + return return_type