Skip to content

Implementing mutmut and other minor fixes and updates - #173

Merged
petermcd merged 2 commits into
mainfrom
mutmut
Oct 5, 2026
Merged

petermcd merged 2 commits into
mainfrom
mutmut

Conversation

@petermcd

@petermcd petermcd commented Oct 5, 2026 •

Copy link
Copy Markdown
Owner

Improving testing by testing mut out mutants
Fixed dependencies

Summary by Sourcery

Improve project quality and release automation by adding mutation testing, expanding test coverage, updating dependencies, and fixing feed item validation.

Bug Fixes:

  • Correct feed item validation error messages and preserve validated request parameters when creating feed items.

Enhancements:

  • Add comprehensive coverage for feed items, date helpers, and missing authentication scenarios.
  • Add mutation-testing configuration and organize development dependencies into dedicated groups.
  • Add package discovery configuration and update the project release version.

Build:

  • Update development and lint dependencies, including security-related urllib3 and mutation-testing tooling.

CI:

  • Run tests with the development dependency group and update the uv setup action used by CI workflows.
  • Trigger publishing workflow runs on pushes to the main branch.

Documentation:

  • Record the project updates in the changelog.

Tests:

  • Expand unit tests for feed item creation and validation, date conversion helpers, and endpoint authentication behavior.

Chores:

  • Refresh the locked dependency set and update repository ignore rules.

@petermcd petermcd self-assigned this Oct 5, 2026
@petermcd petermcd added enhancement New feature or request dependencies Pull requests that update a dependency file labels Oct 5, 2026
@sourcery-ai

sourcery-ai Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Reviewer's Guide

The PR introduces mutmut-based mutation testing and broader unit coverage, refreshes and locks development dependencies, adds package discovery/versioning updates, fixes FeedItem diagnostics and typing, and updates CI triggers and tooling. Reviewers should verify the mutmut command works with the project’s pytest configuration and address the date-format test’s overwritten parametrized inputs.

Sequence diagram for FeedItem creation validation

sequenceDiagram
    participant Caller
    participant FeedItem
    participant MonzoAuth

    Caller->>FeedItem: _create()
    FeedItem->>FeedItem: _validate_feed_params()
    alt valid feed type and parameters
        FeedItem->>MonzoAuth: make_request(path=/feed, method=POST, data=data)
    else invalid feed type or missing required parameter
        FeedItem-->>Caller: MonzoArgumentError
    end
Loading

File-Level Changes

Change Details Files
Added mutation-testing support and refreshed development tooling and dependency locking.
  • Added mutmut configuration to replace the prior Cosmic Ray setup, using the locked uv environment and test selection.
  • Updated development dependencies, linting/test tools, urllib3 security pinning, package discovery configuration, and the lockfile.
  • Bumped the package version and recorded release/configuration housekeeping updates.
pyproject.toml
uv.lock
CHANGELOG.rst
.gitignore
Expanded automated test coverage for endpoint behavior, date helpers, and authentication validation.
  • Added feed-item success-path tests that verify object state and generated POST payloads.
  • Added feed-item validation tests for unsupported types and missing required parameters.
  • Added helper conversion tests and Monzo missing-access-token exception coverage.
  • Introduced a minor test-fixture issue in the date-format parametrized test: its inputs are overwritten, so all cases exercise the same value.
tests/test_feed_item.py
tests/test_helpers.py
tests/test_monzo.py
Improved FeedItem typing, request-data construction, and validation diagnostics.
  • Added explicit type annotations for module constants, slots, validation results, and request data.
  • Simplified parameter iteration while preserving generated params[...] request fields.
  • Corrected the required-parameter error message to include the actual feed type.
monzo/endpoints/feed_item.py
Adjusted CI publishing and validation workflows.
  • Enabled publishing workflow runs on pushes to main in addition to releases and manual dispatch.
  • Upgraded the pinned setup-uv action from v10.1.0 to v10.2.0 across workflows.
.github/workflows/publish.yml
.github/workflows/uv.yml

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
Contributor

Choose a reason for hiding this comment

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

Hey - I've found 3 issues

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

## Individual Comments

### Comment 1
<location path=".github/workflows/publish.yml" line_range="8" />
<code_context>
   release:
     types:
       - published
+  push:
+    branches:
+      - main
</code_context>
<issue_to_address>
**Main pushes publish unreleased versions**

When a commit with a not-yet-published package version reaches `main` and the checks/build pass, `pypi-publish` builds and uploads the package to PyPI without a published release. `skip-existing` does not stop the first upload, so users receive the main-branch build and the later release cannot replace it.

Trigger publishing only from a published GitHub release and remove the `main` push trigger.
</issue_to_address>

### Comment 2
<location path="tests/test_helpers.py" line_range="54" />
<code_context>
+            date: The datetime object to convert.
+            expected_date_str: The expected string representation of the datetime object.
+        """
+        date = datetime(year=2024, month=6, day=1, hour=12, minute=34, second=56, tzinfo=UTC)
+        expected_date_str = "2024-06-01T12:34:56Z"
+        assert format_date(date) == expected_date_str
</code_context>
<issue_to_address>
**Other date cases go unchecked**

When `test_format_date` runs for a non-first parametrized case, `test_format_date` overwrites both parametrized arguments with the hard-coded 2024 date and string, so every case checks the same input. Regressions for other dates pass pytest, allowing `Transaction.fetch` to send incorrectly formatted `since` or `before` filters.

Use the parametrized `date` and `expected_date_str` directly in the assertion.
</issue_to_address>

### Comment 3
<location path="pyproject.toml" line_range="61-62" />
<code_context>
-name = "local"
+[tool.mutmut]
+source_paths = [ "monzo/" ]
+runner = "uv run --locked pytest"
+pytest_add_cli_args_test_selection= [ "tests/" ]
</code_context>
<issue_to_address>
**Mutation testing is absent from CI**

When a pull request or main push runs the UV workflow, the UV workflow runs pytest but never invokes mutmut, so CI does not check whether mutants survive and the stated mutation-testing improvement is not enforced on changes.

Add a CI step that runs mutmut, or otherwise make mutation-test results a required check.
</issue_to_address>

Sourcery assessment

Needs a human reviewer. 3 findings to address first, and adding push on main to the publish workflow can automatically publish artifacts for every qualifying commit, rather than only for a published release. Reverting the workflow stops future runs but cannot remove packages or other externally visible release artifacts already published.

Blocking findings: .github/workflows/publish.yml:8, tests/test_helpers.py:54, pyproject.toml:62


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread .github/workflows/publish.yml Resolved
Comment thread tests/test_helpers.py Resolved
Comment thread pyproject.toml Resolved
@petermcd
petermcd merged commit afce719 into main Oct 5, 2026
15 checks passed
@petermcd
petermcd deleted the mutmut branch October 5, 2026 21:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant