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

add type aware flatten method instead of luigi.task.flatten #362

Merged
merged 5 commits into from
Apr 9, 2024

Conversation

kitagry
Copy link
Member

@kitagry kitagry commented Apr 1, 2024

Currently, we use luigi.task.flatten, but this method is not type aware (it return type is always Unknown. Because of this, we wrote missed type here ( it should be List[str], but List[TaskOnKart] ).

So, I introduce type aware flatten method instead of luigi.task.flatten

@kitagry
Copy link
Member Author

kitagry commented Apr 1, 2024

TypeAlias is not support in Python3.9 😮‍💨

@kitagry kitagry marked this pull request as draft April 1, 2024 09:11
gokart/utils.py Outdated
if sys.version_info >= (3, 10):
from typing import TypeAlias

FlattableItems: TypeAlias = T | Iterable['FlattableItems[T]'] | dict[str, 'FlattableItems[T]']
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TypeAlias is required in mypy. from Python 3.12, this will be replaced type statement

gokart/utils.py Outdated
else:
from typing import Union

FlattableItems = Union[T, Iterable['FlattableItems[T]'], dict[str, 'FlattableItems[T]']]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TypeAlias is not supported in Python 3.9. And, | is not supported.

@kitagry kitagry self-assigned this Apr 8, 2024
@kitagry kitagry marked this pull request as ready for review April 8, 2024 10:19
@kitagry kitagry requested a review from yokomotod April 8, 2024 10:20
gokart/utils.py Outdated Show resolved Hide resolved
gokart/utils.py Outdated Show resolved Hide resolved
Copy link
Contributor

@mski-iksm mski-iksm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kitagry LGTM!

Copy link
Collaborator

@hirosassa hirosassa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@Hi-king
Copy link
Member

Hi-king commented Apr 9, 2024

LGTM

@Hi-king Hi-king merged commit fbecb84 into master Apr 9, 2024
5 checks passed
@Hi-king Hi-king deleted the add-flatten-method branch April 9, 2024 01:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants