fix: update type extraction to extract inner types correctly (#3446)

* refactor: Improve post-processing of return type in type extraction.

* feat: Add support for Union[int, Sequence[str]] in post_process_type.

* refactor(langflow): Simplify return type extraction in CustomComponent.

* Refactor: Remove 'Sequence' and 'list' type options in starter projects.

* test: fix assertion

---------

Co-authored-by: italojohnny <italojohnnydosanjos@gmail.com>
This commit is contained in:
Gabriel Luiz Freitas Almeida 2024-08-20 09:48:18 -03:00 • committed by GitHub
commit 037c0902d5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 18 additions and 37 deletions

View file

@ -1,4 +1,4 @@
from typing import Union
from typing import Sequence, Union
import pytest
from pydantic import ValidationError
@ -42,6 +42,8 @@ class TestInput:
assert post_process_type(int) == [int]
assert post_process_type(list[int]) == [int]
assert post_process_type(Union[int, str]) == [int, str]
assert post_process_type(Union[int, Sequence[str]]) == [int, str]
assert post_process_type(Union[int, Sequence[int]]) == [int]
def test_input_to_dict(self):
input_obj = Input(field_type="str")
@ -126,4 +128,4 @@ class TestPostProcessType:
class CustomType:
pass
assert post_process_type(Union[CustomType, int]) == [CustomType, int]
assert set(post_process_type(Union[CustomType, int])) == {CustomType, int}