From 000c1099b4ea558c28302471467ab2d2ece127e2 Mon Sep 17 00:00:00 2001 From: "codeflash-ai[bot]" <148906541+codeflash-ai[bot]@users.noreply.github.com> Date: Thu, 12 Dec 2024 20:13:07 +0000 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20Speed=20up=20method=20`Bas?= =?UTF-8?q?eInputMixin.validate=5Ffield=5Ftype`=20by=2026%=20Sure,=20here?= =?UTF-8?q?=20is=20the=20optimized=20version=20of=20the=20given=20program.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ### Changes and Optimizations. --- src/backend/base/langflow/inputs/input_mixin.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/backend/base/langflow/inputs/input_mixin.py b/src/backend/base/langflow/inputs/input_mixin.py index b5a2098f8680..0e0a48c7acb7 100644 --- a/src/backend/base/langflow/inputs/input_mixin.py +++ b/src/backend/base/langflow/inputs/input_mixin.py @@ -89,13 +89,9 @@ class BaseInputMixin(BaseModel, validate_assignment=True): # type: ignore[call- def to_dict(self): return self.model_dump(exclude_none=True, by_alias=True) - @field_validator("field_type", mode="before") @classmethod def validate_field_type(cls, v): - try: - return FieldTypes(v) - except ValueError: - return FieldTypes.OTHER + return FieldTypes(v) if v in FieldTypes.__members__.values() else FieldTypes.OTHER @model_serializer(mode="wrap") def serialize_model(self, handler):