From 99ed85c03c3acbe9f7061c98bc6a7a45edc19a4a Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Mon, 31 Jul 2023 21:11:41 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(directory=5Freader.py):=20ha?= =?UTF-8?q?ndle=20SyntaxError=20when=20checking=20if=20type=20hint=20is=20?= =?UTF-8?q?used=20but=20not=20imported=20=F0=9F=94=8D=20refactor(directory?= =?UTF-8?q?=5Freader.py):=20improve=20error=20handling=20when=20checking?= =?UTF-8?q?=20if=20type=20hint=20is=20used=20but=20not=20imported?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../langflow/interface/custom/directory_reader.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/backend/langflow/interface/custom/directory_reader.py b/src/backend/langflow/interface/custom/directory_reader.py index b3c8a1883..3357d164f 100644 --- a/src/backend/langflow/interface/custom/directory_reader.py +++ b/src/backend/langflow/interface/custom/directory_reader.py @@ -176,9 +176,14 @@ class DirectoryReader: """ Check if a type hint is used but not imported in the given code. """ - return self._is_type_hint_used_in_args( - type_hint_name, code - ) and not self._is_type_hint_imported(type_hint_name, code) + try: + return self._is_type_hint_used_in_args( + type_hint_name, code + ) and not self._is_type_hint_imported(type_hint_name, code) + except SyntaxError: + # Returns True if there's something wrong with the code + # TODO : Find a better way to handle this + return True def process_file(self, file_path): """