Skip to content

Update packaging, add hatch for tests, maybe fix tests - #200

Merged
mshriver merged 3 commits into
RedHatQE:mainfrom
mshriver:whiplash
Jul 28, 2026
Merged

Update packaging, add hatch for tests, maybe fix tests#200
mshriver merged 3 commits into
RedHatQE:mainfrom
mshriver:whiplash

Conversation

@mshriver

@mshriver mshriver commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Summary by Sourcery

Modernize packaging, linting, and CI configuration, introduce Hatch-managed test and coverage environments, and apply minor code cleanups for consistency and Python 3.10+ support.

New Features:

  • Add Hatch environments and scripts for running tests, coverage, and linting, including a Python/browser test matrix.

Enhancements:

  • Restrict supported Python versions to 3.10+ and cap widgetastic.core to <2.0.0.
  • Refine error messages, locators, and string formatting using f-strings across widgets and tests for clearer diagnostics and consistency.
  • Simplify and group imports throughout the codebase and tests for improved readability.
  • Generate Sphinx API docs via a top-level apidoc import for cleaner documentation configuration.

Build:

  • Update project classifiers and requires-python to reflect official support for Python 3.10–3.13.
  • Add selenium to the dev extras to support browser-based testing.
  • Switch pre-commit configuration from Black/Flake8/PyUpgrade to Ruff-based linting and formatting with updated hooks.

CI:

  • Update test workflow to use Ubuntu 24.04, newer GitHub Actions versions, Hatch-based test execution, an expanded Python/browser matrix, and Hatch-managed coverage combination.
  • Refresh deployment workflow to use Ubuntu 24.04, trusted PyPI publishing via the latest pypa action, and add a package integrity check step before publish.

Documentation:

  • Extend README with instructions for running tests and coverage using Hatch environments and the defined test matrix.

mshriver and others added 3 commits July 28, 2026 08:37
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Claude <noreply@anthropic.com>
@sourcery-ai

sourcery-ai Bot commented Jul 28, 2026

Copy link
Copy Markdown

Reviewer's Guide

Modernizes packaging, testing, and CI by introducing Hatch-based environments and updated Python support, while applying ruff/format-driven code cleanups (import grouping, f-strings, minor refactors) across widgets and tests to keep behavior but improve consistency.

Sequence diagram for running tests via Hatch environments

sequenceDiagram
    actor Developer
    participant Hatch as hatch
    participant Pytest as pytest
    participant Selenium as selenium_grid

    Developer->>Hatch: hatch run test
    Hatch->>Pytest: invoke pytest testing with BROWSER=firefox
    Pytest->>Selenium: create remote WebDriver(session)
    Selenium-->>Pytest: provide browser session
    Pytest-->>Hatch: test results
    Hatch-->>Developer: report exit status and output
Loading

File-Level Changes

Change Details Files
Consolidate and modernize imports and string formatting across widget and test modules without changing behavior.
  • Group multiple symbols from the same module into single import statements for widgets and tests.
  • Replace legacy str.format calls with f-strings for log messages, locators, and exception texts.
  • Simplify control-flow constructs (e.g., remove redundant else after raise/return) and minor locator string cleanups.
src/widgetastic_patternfly4/__init__.py
src/widgetastic_patternfly4/ouia.py
src/widgetastic_patternfly4/table.py
src/widgetastic_patternfly4/select.py
src/widgetastic_patternfly4/button.py
src/widgetastic_patternfly4/menu.py
src/widgetastic_patternfly4/formselect.py
src/widgetastic_patternfly4/alert.py
src/widgetastic_patternfly4/pagination.py
src/widgetastic_patternfly4/dropdown.py
src/widgetastic_patternfly4/chipgroup.py
src/widgetastic_patternfly4/donutchart.py
src/widgetastic_patternfly4/bulletchart.py
src/widgetastic_patternfly4/navigation.py
src/widgetastic_patternfly4/card.py
src/widgetastic_patternfly4/linechart.py
src/widgetastic_patternfly4/progress.py
src/widgetastic_patternfly4/radio.py
src/widgetastic_patternfly4/tabs.py
src/widgetastic_patternfly4/clipboardcopy.py
src/widgetastic_patternfly4/modal.py
src/widgetastic_patternfly4/switch.py
src/widgetastic_patternfly4/contextselector.py
src/widgetastic_patternfly4/duallistselector.py
src/widgetastic_patternfly4/title.py
testing/test_table.py
testing/test_dropdown.py
testing/test_formselect.py
testing/test_cardview.py
testing/test_chipgroup.py
testing/test_slider.py
testing/ouia/test_modal_ouia.py
testing/ouia/test_dropdown_ouia.py
testing/test_contextselector.py
testing/test_duallistselector.py
testing/test_menu.py
testing/test_modal.py
testing/test_nav.py
testing/test_optionsmenu.py
testing/test_switch.py
testing/test_tabs.py
testing/ouia/test_table_ouia.py
testing/test_descriptionlist.py
testing/test_radio.py
testing/test_title.py
testing/test_pagination.py
testing/test_select.py
testing/test_drawer.py
testing/ouia/test_contextselector_ouia.py
testing/conftest.py
Update packaging metadata and dev tooling to use Hatch, newer Python versions, and ruff-based linting.
  • Raise supported Python versions to 3.10–3.13, drop 3.8/3.9, tighten widgetastic.core dependency range, and add selenium to dev extras.
  • Configure Hatch environments for default dev, test (matrix over Python/browsers), coverage, and lint, plus pytest and ruff configuration blocks in pyproject.
  • Replace black/flake8/pyupgrade pre-commit hooks with ruff and ruff-format plus updated pre-commit-hooks.
  • Document Hatch-based test and coverage workflows in the README.
pyproject.toml
README.md
.pre-commit-config.yaml
Align CI workflows with Hatch-based environments, updated Python matrix, and trusted PyPI publishing.
  • Update tests GitHub Actions workflow to python 3.10–3.13, Ubuntu 24.04, newer actions versions, and to run tests via Hatch matrix envs and coverage env.
  • Adjust coverage submission workflow to use Hatch coverage env and newer actions/Codecov versions.
  • Modernize deploy workflow for Ubuntu 24.04, Python 3.13, updated actions, twine check, and trusted PyPI publishing via pypa/gh-action-pypi-publish.
.github/workflows/tests.yaml
.github/workflows/deploy.yml
Sphinx docs build minor refactor to import apidoc_main at module level.
  • Move sphinx.ext.apidoc.main import to module top-level and simplify run_apidoc helper accordingly.
docs/conf.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 2 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path=".github/workflows/deploy.yml" line_range="21-26" />
<code_context>
       - name: Install dependencies
-        run: pip install twine
+        run: pip install pip twine -U
       - name: Build a wheel
         run: pip wheel --no-deps -w dist .
+      - name: Test package
+        run: twine check dist/*
</code_context>
<issue_to_address>
**suggestion:** The publish job only builds wheels; consider also building an sdist via `python -m build` for broader compatibility.

Currently the job only builds wheels with `pip wheel` and uploads whatever is in `dist/`. Some consumers (e.g. distro packagers or unusual platforms) expect an sdist as well. Using `python -m build` (after `pip install build` if needed) will produce both wheel and sdist, and `pypa/gh-action-pypi-publish` will upload both automatically.

```suggestion
      - name: Install dependencies
        run: pip install --upgrade pip build twine
      - name: Build distributions
        run: python -m build
      - name: Test package
        run: twine check dist/*
```
</issue_to_address>

### Comment 2
<location path="docs/conf.py" line_range="14" />
<code_context>
 import os
 import sys

+from sphinx.ext.apidoc import main as apidoc_main
+
 modules_path = os.path.abspath("../src/widgetastic_patternfly4")
</code_context>
<issue_to_address>
**suggestion (bug_risk):** Importing `sphinx.ext.apidoc` at module import time can make `conf.py` more fragile outside the Sphinx runtime.

This import used to be inside `run_apidoc`, so tools could import `conf.py` without Sphinx installed as long as they didn’t call that function. Moving it to the module level forces all consumers of `conf.py` to have `sphinx.ext.apidoc` available. To keep `conf.py` usable in non-docs contexts, either move the import back inside `run_apidoc` or wrap it in a try/except ImportError.

Suggested implementation:

```python
import os
import sys

modules_path = os.path.abspath("../src/widgetastic_patternfly4")

```

```python
def run_apidoc(_):
    from sphinx.ext.apidoc import main as apidoc_main

    cur_dir = os.path.abspath(".")
    output_path = os.path.join(cur_dir, "source")
    apidoc_main(["-e", "-f", "-o", output_path, modules_path, "--force"])

```
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread .github/workflows/deploy.yml
Comment thread docs/conf.py
@mshriver
mshriver merged commit f51d23c into RedHatQE:main Jul 28, 2026
3 of 11 checks passed
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