Skip to content

feat: rewrite openqa-label-known-issues in Python#612

Draft
okurz wants to merge 7 commits into
os-autoinst:masterfrom
okurz:feature/openqa_auto_review_python
Draft

feat: rewrite openqa-label-known-issues in Python#612
okurz wants to merge 7 commits into
os-autoinst:masterfrom
okurz:feature/openqa_auto_review_python

Conversation

@okurz

@okurz okurz commented Jun 18, 2026

Copy link
Copy Markdown
Member

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

okurz added 7 commits June 17, 2026 15:14
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant