Skip to content

DEV: addres issue #73 - #74

Open
GavinHuttley wants to merge 2 commits into
HuttleyLab:developfrom
GavinHuttley:develop
Open

DEV: addres issue #73#74
GavinHuttley wants to merge 2 commits into
HuttleyLab:developfrom
GavinHuttley:develop

Conversation

@GavinHuttley

@GavinHuttley GavinHuttley commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

Summary by Sourcery

Refine logging version tests to use a reusable dynamic-module fixture and update development tooling versions.

Build:

  • Update dev dependencies in pyproject.toml, including bumping ruff and mypy versions.

Tests:

  • Add a pytest fixture to create temporary importable modules for logging/version tests and clean them up after use.
  • Refactor logging-related tests to use the new dynamic-module fixture instead of writing test files into the repository tree.

[CHANGED] Explicitly invalidate import caches, plus
    isolate temp modules and improve cleanup.
@sourcery-ai

sourcery-ai Bot commented Aug 3, 2026

Copy link
Copy Markdown

Reviewer's Guide

Introduce a reusable pytest fixture for creating temporary importable modules in tests and refactor logging/version tests to use it, while also updating development dependency versions in pyproject.toml and the lockfile.

Flow diagram for pytest fixture-based temporary module creation in tests

flowchart LR
    A[Logging/version tests start] --> B[Use reusable pytest fixture to create temporary importable module]
    B --> C[Fixture writes module contents to temporary directory]
    C --> D[Fixture adjusts sys.path or package structure so module is importable]
    D --> E[Tests import temporary module]
    E --> F[Tests exercise logging and version behavior using imported module]
Loading

File-Level Changes

Change Details Files
Add a reusable pytest fixture to create temporary importable modules and ensure they are cleaned up between tests.
  • Import importlib to manage dynamic module loading and cache invalidation.
  • Create make_module fixture that writes Python source files into a tmp_path, prepends the directory to sys.path, invalidates import caches, imports modules, and tracks created module names.
  • Ensure created modules are removed from sys.modules after each test to avoid cross-test contamination.
tests/test_logging.py
Refactor logging/version-related tests to use the new fixture instead of manipulating TEST_ROOTDIR and sys.path directly.
  • Update test_log_versions_uninstalled_module_does_not_raise to create a temporary module via make_module and pass it to LOGGER.log_versions.
  • Update test_get_version_for_package to create temporary modules with callable and list-based version attributes using make_module, and assert get_version_for_package behavior for both string and module inputs.
  • Update test_log_versions_unresolvable_version_logs_unknown to use make_module for a module without a version attribute instead of writing files to TEST_ROOTDIR.
tests/test_logging.py
Update development tooling dependency versions.
  • Bump ruff from 0.15.22 to 0.16.1 in the dev dependency group.
  • Raise minimum mypy version from 2.1.0 to 2.3.0.
  • Regenerate or update uv.lock to reflect new dependency versions and constraints.
pyproject.toml
uv.lock

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

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity · 0 duplication

Metric Results
Complexity 0
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@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 reviewed your changes and they look great!


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.

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