-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Implement mypy plugin for luigi.Task
#3315
Conversation
2b231bc
to
9d1f72e
Compare
tox-env: flake8 | ||
- python-version: 3.9 | ||
- python-version: "3.10" |
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.
use python 3.10 because docs build failed on 3.9
python for flake 8 also updated as a represented environment
] | ||
) | ||
|
||
self.assertIn( |
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.
This part shows errors when assign invalid type for task arguments
4df2730
to
a4d8512
Compare
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.
LGTM. Just a mention/question about python versions
# | ||
# However, we also want attributes defined in the subtype to override ones defined | ||
# in the parent. We can implement this via a dict without disrupting the attr order | ||
# because dicts preserve insertion order in Python 3.7+. |
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.
Luigi still advertises to be 3.6 compatible. Though, support for 3.6 should be removed (readme reference, tox reference, github actions test execution, etc.).
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.
I saw elsewhere in this PR that the mypy stuff requires 3.8 or later. What is the behavior when someone tries to use it with 3.6 or 3.7?
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.
I saw elsewhere in this PR that the mypy stuff requires 3.8 or later
Sorry about your confusing.
I made a mistake to set a type annotations like list[Any]
which supported after 3.8
I fixed this issue, the tests worked on 3.6 and 3.7.
I did not check python 3.6 and 3.7 on the tests.
I'll check how it works on Python 3.6 via tests.
If the test become flaky, one of workaround is ommit supporting mypy plugion on 3.6
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.
After inspecting issues about python 3.6 and 3.7, some built-in features are lacking (e.g. some type annotation features like Final
and Literal
as well as dict
behaviors).
Can I want to omit these versions for this plugin because this feature is not core required to use luigi?
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.
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.
Yeah, i'm fine with the included solution (requiring a minimum python version to import and use the mypy plugin).
For some reason, the 3.9 version of docs and flake8 are being expected. Although I've approved the PR and am a maintainer of the project, I'm not being allowed to click merge due to 2 statuses missing. |
To merge, we may require a Spotify employee who has the appropriate permissions. I think the CI is trying to wait on some of the tests expected by the @RRap0so , would you be able to look and possibly merge anyway? (I cannot merge, the button is grayed-out saying |
@dlstadther all done 👍 |
luigi.Task
Description
Note
Motivation and Context
This PR aims to solve the following issues.
luigi.Task
cannot be type-checked when initializing it.luigi.Parameter()
is notstr
Have you tested this? If so, how?