Skip to content

Migrate to uv, ruff, and pyproject.toml#663

Merged
rtibbles merged 5 commits into
learningequality:mainfrom
rtibblesbot:issue-662-cb05a4
Jun 2, 2026
Merged

Migrate to uv, ruff, and pyproject.toml#663
rtibbles merged 5 commits into
learningequality:mainfrom
rtibblesbot:issue-662-cb05a4

Conversation

@rtibblesbot

@rtibblesbot rtibblesbot commented Mar 31, 2026

Copy link
Copy Markdown
Contributor

Summary

Migrate ricecooker from pip/tox/setup.py/black/flake8 to uv/ruff/pyproject.toml, matching the approach established in the Kolibri ecosystem (learningequality/kolibri#14457).

  • pyproject.toml replaces setup.py, setup.cfg, pytest.ini, and MANIFEST.in as the single source of project metadata, dependencies, build config, and tool settings
  • Versioning switches from hardcoded __version__ + bumpversion to setuptools-scm with importlib.metadata
  • tox.ini removed; CI workflows use uv run directly via astral-sh/setup-uv@v7
  • Linting/formatting migrated from black + flake8 + reorder-python-imports to ruff
  • Pre-commit config updated with ruff hooks and uv-lock sync hook
  • exclude-newer cooldown configured in [tool.uv] for supply chain safety
  • Developer docs, Makefile, AGENTS.md, and CLAUDE.md updated for uv-based workflow
  • Fix comparison-as-assignment bugs found by ruff: == used instead of = for SETTINGS assignment in chefs.py (deprecated setting migration was silently broken)
  • Fix PDFParser.open() file handle leak on Windows when CustomPDFReader raises on an empty/corrupt PDF; consolidate test fixture download logic into conftest.py as download_fixture_file — downloads atomically via a .tmp sidecar, skips on network failure or non-200 response, and re-downloads zero-byte files from interrupted prior runs (was causing CI failures on Windows)

References

Closes #662

Reference implementation: learningequality/kolibri#14457

Reviewer guidance

  • pyproject.toml — verify dependency completeness against the old setup.py install_requires and extras_require, check setuptools-scm and PEP 735 dependency group config
  • CI workflows (pythontest.yml, pre-commit.yml, python-publish.yml) — the tox-to-uv migration and astral-sh/setup-uv@v7 setup
  • ricecooker/__init__.py:8-14 — version now uses importlib.metadata.version() instead of a hardcoded string
  • ricecooker/chefs.py — fixed === bug in deprecated setting migration (silent no-op before this PR)

To test locally: uv sync --group dev && uv run pytest

AI usage

Implemented by Claude Code following a plan derived from the Kolibri uv migration (learningequality/kolibri#14457). Changes were reviewed against the issue acceptance criteria.


@rtibblesbot's comments are generated by an LLM, and should be evaluated accordingly

How was this generated?
  • Ran pre-flight CI checks (lint, format, tests) and verified all pass
  • Rebased onto the target branch and resolved any conflicts
  • Reorganized commit history into clean, logical commits
  • Audited the diff to ensure only issue-relevant files are changed
  • Built PR body from the repository's PR template with evidence blocks

status

@rtibblesbot rtibblesbot marked this pull request as ready for review April 1, 2026 01:52

@rtibbles rtibbles left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this could do with being rebased onto latest main, and including uv specific updates in AGENTS.md and CLAUDE.md

@rtibblesbot

Copy link
Copy Markdown
Contributor Author

Rebased onto latest main and added uv-specific workflow documentation to both AGENTS.md and CLAUDE.md (commit 765eb3c).

@rtibblesbot rtibblesbot force-pushed the issue-662-cb05a4 branch 2 times, most recently from 1a0ca45 to 40a534e Compare April 7, 2026 00:03
@rtibbles rtibbles self-assigned this Apr 7, 2026
@rtibblesbot rtibblesbot force-pushed the issue-662-cb05a4 branch 2 times, most recently from dd17095 to b504482 Compare April 10, 2026 15:17
@learningequality learningequality deleted a comment from rtibblesbot May 29, 2026
@learningequality learningequality deleted a comment from rtibblesbot May 29, 2026
@learningequality learningequality deleted a comment from rtibblesbot Jun 1, 2026

@rtibbles rtibbles left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Incorrect line length conventions, improperly committed files.

The reformatting commit needs to be redone to avoid churn.

The commit history should be amended.

Comment thread PLAN/clarifications.md Outdated
Comment thread pyproject.toml Outdated
Comment thread REVIEWER_FEEDBACK.md Outdated
@rtibblesbot

Copy link
Copy Markdown
Contributor Author

All reviewer feedback has been addressed:

  1. PLAN/ files not committed — PLAN/ and REVIEWER_FEEDBACK.md remain untracked; the workspace commit adds only ISSUE.md. ✓

  2. pyproject.toml ruff config — Aligned with Kolibri convention: line-length = 88 for the formatter, [tool.ruff.lint.pycodestyle] max-line-length = 160 to avoid flagging existing long lines. Reformatting commit redone with these settings (54 files, net −38 lines). ✓

  3. REVIEWER_FEEDBACK.md not committed — Confirmed untracked. ✓

Local verification: uvx prek run --all-files — all hooks pass. uv run pytest — 395 passed, 12 skipped.

PHASE_COMPLETE

@rtibblesbot rtibblesbot force-pushed the issue-662-cb05a4 branch 3 times, most recently from 333e730 to 73f158b Compare June 2, 2026 01:40
Replace setup.py/setup.cfg with pyproject.toml (setuptools backend, PEP 735
dependency groups, setuptools-scm versioning). Remove tox.ini, pytest.ini,
MANIFEST.in. Add uv.lock. Configure ruff (line-length=88, max-line-length=160)
and replace black/flake8/reorder-python-imports with ruff in
.pre-commit-config.yaml, adding uv-lock hook. Configure exclude-newer cooldown
with le-utils exemption.
Replace hardcoded __version__ with importlib.metadata.version(). Update
docs/conf.py to match.
Replace setup-python/tox with setup-uv@v7 in test workflow. Replace
pre-commit/action with prek in linting workflow. Use uv build in publish
workflow. Switch dependabot from pip to uv ecosystem. Update ReadTheDocs
config to install via uv. Update CONTRIBUTING.md with uv-based setup
instructions. Update Makefile to use uv, ruff, and prek. Update AGENTS.md
and CLAUDE.md with uv-specific guidance.
Apply ruff auto-fixes and formatting across the codebase to comply with the
new ruff configuration (replacing black/flake8/reorder-python-imports).
PDFParser.open() leaked a file handle on Windows if CustomPDFReader raised
(because __enter__ failing means __exit__/close() is never called). Wrap
the CustomPDFReader call in try/except to ensure close() runs on error.

download_fixture_file previously opened local_path for writing before
making the network request, leaving empty files on timeout. Download to a
.tmp sidecar first, replace atomically on success, skip on
requests.RequestException or non-200 response, and re-download zero-byte
files from interrupted prior runs.

Consolidate _save_file_url_to_path wrapper (was a thin re-export) and remove
post-download assert os.path.exists checks — download_fixture_file now
calls pytest.skip() instead of returning normally on failure.

@rtibbles rtibbles left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Good work!

@rtibbles rtibbles merged commit 0da59ed into learningequality:main Jun 2, 2026
21 checks passed
@rtibblesbot rtibblesbot deleted the issue-662-cb05a4 branch June 2, 2026 14:40
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.

Migrate Python tooling to uv and ruff

2 participants