Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Core feature] Generic alias support #5737

Open
2 tasks done
wild-endeavor opened this issue Sep 11, 2024 · 2 comments
Open
2 tasks done

[Core feature] Generic alias support #5737

wild-endeavor opened this issue Sep 11, 2024 · 2 comments
Assignees
Labels
enhancement New feature or request flytekit FlyteKit Python related issue

Comments

@wild-endeavor
Copy link
Contributor

wild-endeavor commented Sep 11, 2024

Motivation: Why do you think this is important?

flytekit currently does not have generic alias support. That is, while this works

@task
def t1(nodelist: List[int] | None = None):
    print(nodelist)

this does not

@task
def t2(nodelist: list[int] | None = None):
    print(nodelist)

If you try to run this, you get the error isinstance() argument 2 cannot be a parameterized generic that's mentioned in docs for standard types.

Propose: Link/Inline OR Additional context

The usage of isinstance is currently coming from the assert_type call in the type engine. Kinda worked around that in here https://github.com/flyteorg/flytekit/pull/2743/files and got the trivial case above working but additional tests and more complex cases need to be considered.

Are you sure this issue hasn't been raised already?

  • Yes

Have you read the Code of Conduct?

  • Yes
@wild-endeavor wild-endeavor added enhancement New feature or request untriaged This issues has not yet been looked at by the Maintainers labels Sep 11, 2024
@eapolinario eapolinario added flytekit FlyteKit Python related issue and removed untriaged This issues has not yet been looked at by the Maintainers labels Sep 19, 2024
@eapolinario eapolinario self-assigned this Sep 19, 2024
@wild-endeavor wild-endeavor reopened this Oct 7, 2024
@wild-endeavor
Copy link
Contributor Author

Ensure that Optional[list[int]] also works.

@blaketastic2
Copy link

We're actually seeing an issue relating to list[str] when the code goes through the ListTransformer path. https://github.com/flyteorg/flytekit/blob/effa4431a3de7b7c03b62b0bab7eb949311e00ad/flytekit/core/type_engine.py#L1331-L1370

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request flytekit FlyteKit Python related issue
Projects
Status: Done
Development

No branches or pull requests

3 participants