-
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
Improve optional parameters #3079
Conversation
79f3733
to
dbb2886
Compare
Do you think that the fail in CI is due to this PR? I don't think so but I am not sure. |
The errors listed don't look related to these changes. @ckiosidis do you have insights? This was the first time i've looked at PR-specific unittests for Luigi since the move to Github Actions. I assume |
dbb2886
to
3cef59d
Compare
Hello |
class OptionalListParameter(OptionalParameterMixin, ListParameter): | ||
"""Class to parse optional list parameters.""" | ||
|
||
expected_type = tuple |
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.
is OptionalListParameter intentionally a tuple? As opposed to a list?
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.
It is intentional because the _warn_on_wrong_param_type
is called after normalize
which calls recursively_freeze
on the value, thus the list
is transformed into a tuple
before the type is checked. That's why we expect a tuple here.
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.
Ah right. I vaguely recall that confusion. I believe I added List Parameter and Tuple Parameter separately and later wished I hadn't added both. But alas, we have them both and treat them nearly the same.
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.
Indeed it would be simpler to have only one of these 2.
5a82a8a
to
d9e86f1
Compare
class OptionalListParameter(OptionalParameterMixin, ListParameter): | ||
"""Class to parse optional list parameters.""" | ||
|
||
expected_type = tuple |
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.
Ah right. I vaguely recall that confusion. I believe I added List Parameter and Tuple Parameter separately and later wished I hadn't added both. But alas, we have them both and treat them nearly the same.
Description
Update OptionalParameter and add several other parameter classes for other types.
Motivation and Context
Parameters raise warnings when their default value is None. As far as I know, it is only possible to use OptionalParameter for string type so I added optional classes for other types.
Have you tested this? If so, how?
I have included unit tests.