Skip to content

Mondernise maintenance#93

Merged
GavinHuttley merged 3 commits into
HuttleyLab:developfrom
GavinHuttley:develop
May 7, 2026
Merged

Mondernise maintenance#93
GavinHuttley merged 3 commits into
HuttleyLab:developfrom
GavinHuttley:develop

Conversation

@GavinHuttley
Copy link
Copy Markdown
Collaborator

@GavinHuttley GavinHuttley commented May 7, 2026

Summary by Sourcery

Modernize the project's packaging and CI workflows around uv and hatch, and align linting and testing tooling with dependency groups.

New Features:

  • Define a dedicated nox session for code formatting via ruff.
  • Introduce Ruff configuration in a standalone ruff.toml file.

Enhancements:

  • Switch packaging from flit to hatchling and configure version sourcing from the package init.
  • Clarify project metadata by setting a static description and tightening the supported Python version range.
  • Move test and development dependencies to hatch/uv dependency groups for cleaner environment management.
  • Adopt uv for building distributions and running tests and linters across CI workflows.
  • Standardize CI to run tests and coverage via uv + nox and to format code via a nox fmt session.
  • Update nox sessions to install the project with test dependency groups and to run coverage on Python 3.14.
  • Tighten dependency security by excluding packages newer than a short time window in uv configuration.

Build:

  • Replace the Python build invocation with uv build in the release pipeline.

CI:

  • Refactor release, test, and lint GitHub Actions to rely on uv-managed environments and commands.
  • Simplify cogent3 dev CI by installing the project and overriding cogent3 via uv-managed environments.

Chores:

  • Remove the legacy uv.lock file now that dependency management is handled via pyproject and uv configuration.

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented May 7, 2026

Reviewer's Guide

Modernizes the packaging, linting, and CI setup by migrating from flit to hatch/uv, restructuring dependency groups, externalizing Ruff config, and simplifying GitHub workflows and nox sessions around uv and Python 3.14.

Flow diagram for updated nox sessions and dependency groups

flowchart TD
  Dev["Developer_or_CI"] --> NoxTestCall["Call_nox_session_test"]
  Dev --> NoxTestcovCall["Call_nox_session_testcov"]
  Dev --> NoxFmtCall["Call_nox_session_fmt"]

  subgraph Nox_Config
    Noxfile["noxfile_py"]
    PyProject["pyproject_toml"]
    DepGroups["dependency_group_test"]
    DepGroupsDev["dependency_group_dev"]
  end

  NoxTestCall --> Noxfile
  NoxTestcovCall --> Noxfile
  NoxFmtCall --> Noxfile

  subgraph Session_test
    ST_Install["session_install_editable_with_test_group"]
    ST_Chdir["session_chdir_tests"]
    ST_Pytest["session_run_pytest_with_markers"]
  end

  subgraph Session_testcov
    SC_Install["session_install_editable_with_test_group"]
    SC_Chdir["session_chdir_tests"]
    SC_Pytest["session_run_pytest_with_coverage"]
  end

  subgraph Session_fmt
    SF_InstallRuff["session_install_ruff"]
    SF_RuffCheck["session_run_ruff_check_fix_only"]
    SF_RuffFormat["session_run_ruff_format"]
  end

  Noxfile --> ST_Install
  ST_Install --> DepGroups
  ST_Install --> PyProject
  ST_Install --> ST_Chdir
  ST_Chdir --> ST_Pytest

  Noxfile --> SC_Install
  SC_Install --> DepGroups
  SC_Install --> PyProject
  SC_Install --> SC_Chdir
  SC_Chdir --> SC_Pytest

  Noxfile --> SF_InstallRuff
  SF_InstallRuff --> SF_RuffCheck
  SF_RuffCheck --> SF_RuffFormat

  subgraph UV_Integration
    UV_Run_Test["uv_run_with_group_test"]
    UV_Run_Dev["uv_run_with_group_dev"]
  end

  UV_Run_Test --> NoxTestCall
  UV_Run_Test --> NoxTestcovCall
  UV_Run_Dev --> NoxFmtCall

  PyProject --> DepGroups
  PyProject --> DepGroupsDev
Loading

File-Level Changes

Change Details Files
Switch build backend from flit to hatchling and align project metadata and dependency structure with uv/hatch conventions.
  • Change [build-system] to use hatchling as the build backend and dependency.
  • Adjust requires-python to use an exclusive upper bound (<3.15) instead of inclusive (<=3.14).
  • Promote description from dynamic metadata to a static field while keeping version dynamic via a hatch version path.
  • Replace [project.optional-dependencies] with [dependency-groups] for test and dev groups, and drop flit from dev dependencies.
  • Add [tool.hatch.version] pointing to src/mutation_motif/init.py for version management.
  • Remove [tool.flit.sdist] configuration now that flit is no longer used.
  • Add [tool.uv] exclude-newer setting to constrain dependency freshness.
pyproject.toml
Standardize linting configuration by moving Ruff settings from pyproject.toml into a dedicated ruff.toml and slightly adjusting rules.
  • Remove all Ruff-related configuration tables from pyproject.toml.
  • Create ruff.toml with equivalent Ruff settings (exclude paths, formatting, isort, etc.) and update ignores to include COM812 and some additional test-specific ignores.
  • Ensure known-first-party is aligned to mutation_motif rather than cogent3.
pyproject.toml
ruff.toml
Align nox sessions with uv-style editable installs and add a dedicated formatting session using Ruff on Python 3.14.
  • Update test and testcov sessions to install the project with uv-style groups ("-e", ".", "--group", "test").
  • Bump the testcov session Python version from 3.12 to 3.14.
  • Introduce a new fmt nox session that installs Ruff and runs ruff check --fix-only and ruff format.
noxfile.py
Refactor CI workflows to use uv for environment management, builds, tests, and formatting, and to align with the new dependency groups.
  • In release.yml, drop actions/setup-python usage and rely on astral-sh/setup-uv for Python selection and caching, using uv run --group test nox for matrix tests.
  • In release.yml build job, replace pip-based build invocation with uv build and use setup-uv for tooling installation.
  • In linters.yml, replace manual Python + pip + Ruff setup with setup-uv and run uv run --group dev nox -s fmt for formatting, then commit changes.
  • In ci-cogent3-dev.yml, use uv venv and uv pip install -e . --group test to install project and tests, then override cogent3 with the dev branch and run tests via uv run pytest.
  • In testing_develop.yml, similarly replace manual venv/nox installation with uv run --group test nox ... for test matrix runs.
.github/workflows/release.yml
.github/workflows/linters.yml
.github/workflows/ci-cogent3-dev.yml
.github/workflows/testing_develop.yml
noxfile.py
Prune obsolete lock/config files to reflect the new tooling setup.
  • Delete uv.lock, presumably to allow regeneration under the new configuration.
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.

Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

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, and left some high level feedback:

  • The updated noxfile.py uses session.install("-e", ".", "--group", "test"), but session.install delegates to pip which doesn’t understand --group, so this will likely break local nox runs; consider keeping .[test] for nox and relying on dependency-groups only where tools explicitly support them (e.g. uv).
  • Replacing [project.optional-dependencies] with [dependency-groups] removes support for standard extras like pip install .[test]; if that’s not intentional, you might want to mirror the groups into optional-dependencies for compatibility with non-uv tooling.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The updated `noxfile.py` uses `session.install("-e", ".", "--group", "test")`, but `session.install` delegates to pip which doesn’t understand `--group`, so this will likely break local nox runs; consider keeping `.[test]` for nox and relying on `dependency-groups` only where tools explicitly support them (e.g. uv).
- Replacing `[project.optional-dependencies]` with `[dependency-groups]` removes support for standard extras like `pip install .[test]`; if that’s not intentional, you might want to mirror the groups into `optional-dependencies` for compatibility with non-uv tooling.

## Individual Comments

### Comment 1
<location path="noxfile.py" line_range="8" />
<code_context>
 @nox.session(python=[f"3.{v}" for v in _py_versions])
 def test(session):
-    session.install("-e.[test]")
+    session.install("-e", ".", "--group", "test")
     session.chdir("tests")
     session.run(
</code_context>
<issue_to_address>
**issue (bug_risk):** Using `--group` in `session.install` is likely incompatible with the underlying installer.

`session.install` delegates directly to pip (or `uv pip install`), which don’t understand `--group` in this context, so this call is very likely to fail when the session runs.

To keep group-based CI usage while avoiding breakage in `nox`, consider either retaining the extras install (`session.install("-e.[test]")`) or calling `uv` explicitly via `session.run("uv", "run", "--group", "test", "pytest", ...)` instead of using `session.install` for this.

As written, local `nox` runs are very likely to error when `session.install` is executed.
</issue_to_address>

### Comment 2
<location path="ruff.toml" line_range="34" />
<code_context>
-line-length = 88
-indent-width = 4
-
-target-version = "py310"
-
-[tool.ruff.lint]
</code_context>
<issue_to_address>
**suggestion:** Ruff `target-version` is lower than the declared supported Python versions.

Ruff is set to `target-version = "py310"` while the project targets `>=3.11`. This mismatch can cause Ruff to flag valid 3.11+ syntax or miss issues specific to those versions. Please update `target-version` to at least `"py311"` so linting matches the supported runtime.
</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 noxfile.py
@nox.session(python=[f"3.{v}" for v in _py_versions])
def test(session):
session.install("-e.[test]")
session.install("-e", ".", "--group", "test")
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

issue (bug_risk): Using --group in session.install is likely incompatible with the underlying installer.

session.install delegates directly to pip (or uv pip install), which don’t understand --group in this context, so this call is very likely to fail when the session runs.

To keep group-based CI usage while avoiding breakage in nox, consider either retaining the extras install (session.install("-e.[test]")) or calling uv explicitly via session.run("uv", "run", "--group", "test", "pytest", ...) instead of using session.install for this.

As written, local nox runs are very likely to error when session.install is executed.

Comment thread ruff.toml
line-length = 88
indent-width = 4

target-version = "py310"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

suggestion: Ruff target-version is lower than the declared supported Python versions.

Ruff is set to target-version = "py310" while the project targets >=3.11. This mismatch can cause Ruff to flag valid 3.11+ syntax or miss issues specific to those versions. Please update target-version to at least "py311" so linting matches the supported runtime.

@GavinHuttley GavinHuttley merged commit 33d5e45 into HuttleyLab:develop May 7, 2026
12 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