-
Notifications
You must be signed in to change notification settings - Fork 79
Fix CLI: allow to set falsy values as default #894
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
Conversation
Thank you for contributing to the Leapp project!Please note that every PR needs to comply with the Leapp Guidelines and must pass all tests in order to be mergeable.
To launch regression testing public members of oamg organization can leave the following comment:
Please open ticket in case you experience technical problem with the CI. (RH internal only) Note: In case there are problems with tests not being triggered automatically on new PR/commit or pending for a long time, please consider rerunning the CI by commenting leapp-ci build (might require several comments). If the problem persists, contact leapp-infra. |
|
@oamg/developers I consider it kind of done. I want to however discuss it first to deal with some internals. |
When specifying an option for a leapp CLI command using @add_option decorator, it has not been possible to specify a "falsy" value (or let's say empty) as `default` e.g. empty string, empty list, etc. Start to check NoneType for the `default` parameter properly to allow it to set this. Bump leapp-framework to 6.1. Note: The similar problem is for `choices` and `metavar` parameters. In case of `metavar` it's however ok to ignore empty string. In case of empty `choices` it would lead to the same evaluation as in case of NoneType (any input is ok). So I that the `default` is the only parameter that needs to be checked properly. JIRA: RHEL-86206
MichalHe
left a comment
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 have tested this PR by adding the following lines into commands/upgrade/__init__.py:
...
@command_opt('myflag', default=[])
def upgrade(args, breadcrumbs):
print(args.myflag)
import pdb; pdb.set_trace()Without having the changes introduced in this PR, I observe args.myflag having the value None. With this PR, I have correct value []. LGTM
|
The failing aws test is not related to the changes introduced by this PR, hence merging. |
## Packaging - Bump leapp-framework to 6.1 (oamg#894) ## Framework ### Fixes - Create the /var/lib/leapp directory automatically if missing (oamg#893) ### Enhancements - Recognize configuration files with the .yaml suffix only (oamg#892) ## Leapp (tool) ### Fixes - Fix CLI: allow to set falsy values as default for leapp's command options (oamg#894) ## Modifications - Updated Makefile and drop of rhel7 related artifacts (oamg#905)
## Packaging - Bump leapp-framework to 6.1 (oamg#894) ## Framework ### Fixes - Create the /var/lib/leapp directory automatically if missing (oamg#893) ### Enhancements - Recognize configuration files with the .yaml suffix only (oamg#892) ## Leapp (tool) ### Fixes - Fix CLI: allow to set falsy values as default for leapp's command options (oamg#894) ## Modifications - Updated Makefile and drop of rhel7 related artifacts (oamg#905)
## Packaging - Bump leapp-framework to 6.1 (oamg#894) ## Framework ### Fixes - Create the /var/lib/leapp directory automatically if missing (oamg#893) ### Enhancements - Recognize configuration files with the .yaml suffix only (oamg#892) ## Leapp (tool) ### Fixes - Fix CLI: allow to set falsy values as default for leapp's command options (oamg#894) ## Modifications - Updated Makefile and drop of rhel7 related artifacts (oamg#905)
## Packaging - Bump leapp-framework to 6.1 (#894) ## Framework ### Fixes - Create the /var/lib/leapp directory automatically if missing (#893) ### Enhancements - Recognize configuration files with the .yaml suffix only (#892) ## Leapp (tool) ### Fixes - Fix CLI: allow to set falsy values as default for leapp's command options (#894) ## Modifications - Updated Makefile and drop of rhel7 related artifacts (#905)
When specifying an option for a leapp CLI command using @add_option decorator, it has not been possible to specify a "falsy" value (or let's say empty) as
defaulte.g. empty string, empty list, etc. Start to check NoneType for thedefaultparameter properly to allow it to set this.Bump leapp-framework to 6.1.
Note:
The similar problem is for
choicesandmetavarparameters. In case ofmetavarit's however ok to ignore empty string. In case of emptychoicesit would lead to the same evaluation as in case of NoneType (any input is ok). So I that thedefaultis the only parameter that needs to be checked properly.jira: RHEL-86206