Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@pirat89
Copy link
Member

@pirat89 pirat89 commented Apr 6, 2025

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

@github-actions
Copy link

github-actions bot commented Apr 6, 2025

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.
If you want to request a review or rebuild a package in copr, you can use following commands as a comment:

  • review please @oamg/developers to notify leapp developers of the review request
  • /packit copr-build to submit a public copr build using packit

To launch regression testing public members of oamg organization can leave the following comment:

  • /rerun to schedule basic regression tests using this pr build and leapp-repository*main* as artifacts
  • /rerun 42 to schedule basic regression tests using this pr build and leapp-repository*PR42* as artifacts
  • /rerun-sst to schedule sst tests using this pr build and leapp-repository*main* as artifacts
  • /rerun-sst 42 to schedule sst tests using this pr build and leapp-repository*PR42* as artifacts

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.

@pirat89
Copy link
Member Author

pirat89 commented Apr 6, 2025

@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
@pirat89 pirat89 marked this pull request as ready for review April 7, 2025 09:59
@pirat89 pirat89 requested review from a team and MichalHe April 7, 2025 16:33
Copy link
Member

@MichalHe MichalHe left a 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

@MichalHe
Copy link
Member

MichalHe commented Apr 8, 2025

The failing aws test is not related to the changes introduced by this PR, hence merging.

@MichalHe MichalHe merged commit 372ac68 into oamg:main Apr 8, 2025
21 of 22 checks passed
@pirat89 pirat89 deleted the fix-cli-parsing branch May 13, 2025 15:41
@pirat89 pirat89 added the changelog-checked The merger/reviewer checked the changelog draft document and updated it when relevant label May 13, 2025
pirat89 added a commit to pirat89/leapp that referenced this pull request Aug 14, 2025
## 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)
@pirat89 pirat89 mentioned this pull request Aug 14, 2025
pirat89 added a commit to pirat89/leapp that referenced this pull request Aug 14, 2025
## 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)
pirat89 added a commit to pirat89/leapp that referenced this pull request Aug 14, 2025
## 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)
pirat89 added a commit that referenced this pull request Aug 14, 2025
## 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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug changelog-checked The merger/reviewer checked the changelog draft document and updated it when relevant

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants