From 2212458bef65f9eb883c3b1d4e81873d0d556072 Mon Sep 17 00:00:00 2001 From: italojohnny Date: Thu, 20 Jun 2024 17:12:53 -0300 Subject: [PATCH] fix return value error reported by mypy --- src/backend/base/langflow/template/template/base.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/backend/base/langflow/template/template/base.py b/src/backend/base/langflow/template/template/base.py index ef6082cf8..bbedd14b2 100644 --- a/src/backend/base/langflow/template/template/base.py +++ b/src/backend/base/langflow/template/template/base.py @@ -1,4 +1,4 @@ -from typing import Callable, Union +from typing import Callable, Union, cast from pydantic import BaseModel, Field, model_serializer @@ -9,7 +9,8 @@ from langflow.utils.constants import DIRECT_TYPES class Template(BaseModel): type_name: str = Field(serialization_alias="_type") - fields: list[Input | InputTypes] + fields: list[Union[Input, InputTypes]] + def process_fields( self, @@ -49,7 +50,7 @@ class Template(BaseModel): field = next((field for field in self.fields if field.name == field_name), None) if field is None: raise ValueError(f"Field {field_name} not found in template {self.type_name}") - return field + return cast(Input, field) def update_field(self, field_name: str, field: Input) -> None: """Updates the field with the given name."""