-
Notifications
You must be signed in to change notification settings - Fork 57
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
Conversation
TypeAlias is not support in Python3.9 😮💨 |
c60f535
to
2482321
Compare
2482321
to
6df1af1
Compare
gokart/utils.py
Outdated
if sys.version_info >= (3, 10): | ||
from typing import TypeAlias | ||
|
||
FlattableItems: TypeAlias = T | Iterable['FlattableItems[T]'] | dict[str, 'FlattableItems[T]'] |
There was a problem hiding this comment.
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]']] |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kitagry LGTM!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
LGTM |
Currently, we use
luigi.task.flatten
, but this method is not type aware (it return type is alwaysUnknown
. Because of this, we wrote missed type here ( it should beList[str]
, butList[TaskOnKart]
).So, I introduce type aware flatten method instead of
luigi.task.flatten