Skip to content

feat: modernize repo to use uv and pyproject.toml#437

Draft
farhan wants to merge 4 commits into
openedx:masterfrom
farhan:farhan/modernize-python-repo
Draft

feat: modernize repo to use uv and pyproject.toml#437
farhan wants to merge 4 commits into
openedx:masterfrom
farhan:farhan/modernize-python-repo

Conversation

@farhan

@farhan farhan commented Jul 15, 2026

Copy link
Copy Markdown

Important

PR implemented with the assistance of Claude Code, human-reviewed and improved before pushing to code review.

Summary

Modernize `openedx-webhooks` to uv + pyproject.toml (PEP 621/735) + src/ layout.

Part of openedx/public-engineering#506.

  • Replace `setup.py`/`setup.cfg` with `pyproject.toml` (PEP 621 static metadata)
  • Switch from pip-compile to `uv` with PEP 735 dependency groups; commit `uv.lock`
  • Move the package into a `src/` layout
  • Retain pylint/isort/pycodestyle as on master (ruff deferred to its own epic per #506); coverage config moved into `pyproject.toml`
  • Update `tox.ini` to use `tox-uv` with `uv-venv-lock-runner` (newly introduced — master had no `tox.ini`)
  • Update CI to use `astral-sh/setup-uv`; SHA-pin all actions; add `workflow_call` trigger

Removed

Deleted files: `setup.py`, `setup.cfg`, `requirements/`, `.coveragerc`

Removed Makefile targets:

Target Reason
`check-setup.py` Invoked `setup.py check`; `setup.py` no longer exists
`compile-requirements` pip-compile replaced by `uv lock`; pip-tools no longer used
`install-dev-requirements` pip-sync replaced by `uv sync`; pip-tools no longer used
`pip-compile` pip-compile replaced by `uv lock`; pip-tools no longer used
`pip-compile-upgrade` Superseded by `uv lock --upgrade` in the `upgrade` target

Not included/implemented

  • `release.yml` / `python-semantic-release` — master had no PyPI publish workflow.

Versioning

[Static] `version = "0.1.0"` declared directly in `pyproject.toml` — master had no PyPI publish workflow, so `setuptools-scm` is not used and the version is bumped manually on each release tag.

Testing Notes

This PR has not been manually tested against the repo's own features. Testing relied on CI checks and local agent tooling (`make requirements`, `make lint`, `make test`, `python -m build`). Repo-owner is encouraged to run the repo's feature tests before merging.

Code reviewer notes:

  • `tox.ini` is newly introduced (master had no tox config); all environments use `tox-uv` with `uv-venv-lock-runner` so tox environments are driven by `uv.lock` rather than re-resolving on each run.
  • CI matrix now explicitly enumerates tox environments (`lint`, `mypy`, `docs`, `py312-test`) rather than running a single combined step, making individual failures easier to identify.
  • The branch-protection required check name `Tests (ubuntu-latest, 3.12)` is preserved via a `job-name` matrix override on the `py312-test` entry — no admin access needed to update branch protection.
  • `commitlint.yml` was already present on master before this PR — no behavioral change introduced by this migration.
  • `codecov.yml` is newly added (header comment + reference URL only — no thresholds introduced).
  • `upgrade` target now runs `uv lock --upgrade` instead of pip-compile; the new `requirements` target replaces `install-dev-requirements` with `uv sync --group dev`.

🤖 Generated with Claude Code

Replaces setup.py/setup.cfg with pyproject.toml (PEP 621/735), switches
from pip-compile to uv with PEP 735 dependency groups, and updates CI
to use astral-sh/setup-uv. Lint tooling (pylint/isort) retained as on
master; ruff deferred to a future epic per public-engineering#506.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add test-base group to quality deps so pylint can import requests_mock
  and freezegun when scanning test files (fixes F6401/E0401 errors)
- Fix mypy: add type annotation for _memoized_functions list in utils.py
- Fix mypy: add None guard for settings.GITHUB_OSPR_PROJECT in
  pr_tracking._fix_project_node_fields to satisfy Optional type
- Fix mypy: suppress override signature mismatch in auth.BaseUrlSession
  (intentional simplified signature for URL-prefix wrapping)
- Update pylintrc_tweaks to disable pre-existing pylint violations not
  caught before (pylint 4.x new rules + no previous CI enforcement)
- Regenerate pylintrc via edx_lint with edx-lint 6.1.0
- Fix debug line left in tests/test_rescan.py (import json,sys inline)
- Fix trailing newlines in tests/test_info.py
- Fix line-too-long violations in utils.py and tests/test_rescan.py
- Run isort to fix import ordering across affected files

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The Jinja2/HTML templates under openedx_webhooks/templates/ are
required at runtime by bot_comments.py but were missing from both
the sdist and wheel after the migration to pyproject.toml. The old
setup.py used include_package_data=True + MANIFEST.in to capture them;
the new pyproject.toml needs an explicit [tool.setuptools.package-data]
entry to replicate that.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@codecov

codecov Bot commented Jul 16, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 82.35294% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.07%. Comparing base (6b9feb1) to head (c864a4d).

Files with missing lines Patch % Lines
src/openedx_webhooks/tasks/pr_tracking.py 50.00% 1 Missing and 1 partial ⚠️
src/openedx_webhooks/utils.py 75.00% 1 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (6b9feb1) and HEAD (c864a4d). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (6b9feb1) HEAD (c864a4d)
1 0
Additional details and impacted files
@@             Coverage Diff             @@
##           master     #437       +/-   ##
===========================================
- Coverage   89.84%   78.07%   -11.77%     
===========================================
  Files          38       19       -19     
  Lines        3103     1364     -1739     
  Branches      239      168       -71     
===========================================
- Hits         2788     1065     -1723     
+ Misses        281      273        -8     
+ Partials       34       26        -8     
Flag Coverage Δ
unittests 78.07% <82.35%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@farhan
farhan marked this pull request as draft July 16, 2026 13:17
Moves openedx_webhooks under src/ per the migration standard
(public-engineering#506). Updates pyproject.toml (where = ["src"],
source_pkgs for coverage), tox.ini (src/openedx_webhooks paths for
pylint/isort/mypy), Makefile (pylint target), and docs/conf.py
(sys.path to ../src).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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