feat: rewrite openqa-label-known-issues in Python#612
Draft
okurz wants to merge 7 commits into
Draft
Conversation
Motivation: The original bash script was becoming unmaintainable, hard to extend, and tricky to test due to complex regex and common dependency sourcing. Design Choices: Ported the entire logic to Python using httpx and typer. Added a comprehensive pytest-based test suite with 100% statement and branch coverage. Benefits: The script is now highly maintainable, type-safe, has rich logging support, and a rigorous test harness preventing regressions.
Motivation: The help output of the new python tool was missing the detailed usage text that the original bash script displayed. Design Choices: Added the full, multi-line detailed usage instructions to the Typer command docstring. Modified Ruff rules to ignore pydocstyle checks for the CLI script. Benefits: Provides users with the same rich usage context directly when executing the command with '--help'.
Motivation: There was an extra blank line inside the usage help text, and the default value for the '--host' option was not being shown in the help output. Design Choices: Removed the extra blank line inside the docstring. Specified the environment variable lookup as the default value in typer.Option to automatically populate and display it in `--help`. Benefits: The help output is now clean, free of redundant blank lines, and correctly shows the '--host' default value option.
Motivation:
The route path arguments passed to 'openqa-cli' for jobs and job_groups were
incorrectly split into separate arguments, causing API calls to return nothing.
Design Choices:
Modified the route path construction in python to format routes as 'jobs/{id}'
and 'job_groups/{id}' as single arguments with slashes, matching bash behavior.
Benefits:
The script successfully and robustly fetches job details and job group details
using 'openqa-cli' without hanging or returning empty responses.
Motivation: The application was missing a way to configure the output verbosity dynamically from the command line. Design Choices: Implemented standard library 'logging' and added a '--verbose' / '-v' option with count=True via Typer's count Option. Enabled 'Annotated' for clean argument type mapping and direct test executions. Benefits: Users can now supply '-v' (INFO) or '-vv' (DEBUG) options to change the script's log level.
Motivation: Using a verbose if/elif/else tree to map verbosity counts to standard logging levels is less pythonic and doesn't match the project guidelines. Design Choices: Refactored 'setup_logging' to use a dictionary mapping table instead of an if/elif/else block, capping the maximum verbosity cleanly with min(). Benefits: The mapping is more elegant, easier to read, and fully satisfies the python-dev skill guidelines.
Motivation: When matches were found in dry-run mode or during standard runs, there was no standard library logging output explaining which issue/label was matched. Design Choices: Created a module-level logger and replaced raw root logger calls with 'log.info' and 'log.debug' using lazy formatting. Logged successful issue/label match and dry-run actions. Benefits: Executing the script with '-v' or '-vvv' now clearly and dynamically outputs all match, query, and dry-run action log entries.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation:
The original bash script was becoming unmaintainable, hard to extend, and tricky
to test due to complex regex and common dependency sourcing.
Design Choices:
Ported the entire logic to Python using httpx and typer. Added a comprehensive
pytest-based test suite with 100% statement and branch coverage.
Benefits:
The script is now highly maintainable, type-safe, has rich logging support, and
a rigorous test harness preventing regressions.
Related issue: https://progress.opensuse.org/issues/202680