From a099fd05ad574ef9a0342230b2fc45e69c75a685 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Fri, 16 Jun 2023 14:22:14 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A5=20refactor(cache/base.py):=20remov?= =?UTF-8?q?e=20empty=20pass=20statement=20in=20BaseCache=20abstract=20meth?= =?UTF-8?q?od=20=F0=9F=94=A5=20refactor(utils/validate.py):=20remove=20try?= =?UTF-8?q?-except=20block=20in=20create=5Ffunction=20method=20The=20pass?= =?UTF-8?q?=20statement=20in=20the=20BaseCache=20abstract=20method=20is=20?= =?UTF-8?q?redundant=20and=20can=20be=20removed.=20Similarly,=20the=20try-?= =?UTF-8?q?except=20block=20in=20the=20create=5Ffunction=20method=20is=20n?= =?UTF-8?q?ot=20necessary=20as=20the=20exception=20is=20being=20suppressed?= =?UTF-8?q?.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/langflow/cache/base.py | 1 - src/backend/langflow/utils/validate.py | 6 ++---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/backend/langflow/cache/base.py b/src/backend/langflow/cache/base.py index f2ee9854d..85d2e0eed 100644 --- a/src/backend/langflow/cache/base.py +++ b/src/backend/langflow/cache/base.py @@ -27,7 +27,6 @@ class BaseCache(abc.ABC): key: The key of the item. value: The value to cache. """ - pass @abc.abstractmethod def delete(self, key): diff --git a/src/backend/langflow/utils/validate.py b/src/backend/langflow/utils/validate.py index d1353bd77..905b9dd44 100644 --- a/src/backend/langflow/utils/validate.py +++ b/src/backend/langflow/utils/validate.py @@ -1,4 +1,5 @@ import ast +import contextlib import importlib import types from typing import Dict @@ -147,11 +148,8 @@ def create_function(code, function_name): code_obj = compile( ast.Module(body=[function_code], type_ignores=[]), "", "exec" ) - try: + with contextlib.suppress(Exception): exec(code_obj, exec_globals, locals()) - except Exception: - pass - exec_globals[function_name] = locals()[function_name] # Return a function that imports necessary modules and calls the target function