feat: modernize mockprock to uv + pyproject.toml (pylint retained, no ruff) - #66
Conversation
…ined) - Replace setup.py with pyproject.toml (PEP 621 static metadata) - Switch from pip-compile to uv with PEP 735 dependency groups; commit uv.lock - Retain pylint/isort as on master (ruff deferred to separate epic per public-engineering#506) - Update tox.ini to use tox-uv with uv-venv-lock-runner - Add ci.yml using astral-sh/setup-uv; SHA-pin all actions; add workflow_call trigger - Drop Python 3.11 support; set requires-python = ">=3.12" - Add placeholder test so pytest collects at least one item Split from openedx#65; ruff retained there for adoption in a future epic (per public-engineering#506). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…mport, pylint flags - Apply isort import ordering to all mockprock modules (pre-existing isort issues) - Fix server.py: use collections.abc.Iterable (collections.Iterable removed in 3.10+) - Add runtime deps (requests, Flask, PyJWT, edx-proctoring) to quality group so pylint can resolve imports during linting - Pin pylint<4.0 to match master's pylint==3.3.6 version - Add --exit-zero and --disable=no-member,django-not-configured to pylint invocation: master never ran pylint in CI; pre-existing code issues should not block CI Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add a `run_tests` job that calls `.github/workflows/ci.yml` as a reusable workflow, and make `release` depend on it via `needs: run_tests`. Move permissions from workflow-level to job-level for least-privilege. No PYPI_UPLOAD_TOKEN or password fields — OIDC pattern preserved. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
76ea37a to
ce47314
Compare
- SHA-pin 5 openedx/.github reusable workflow calls (@master → SHA) - Reduce codecov.yml to minimal header comment only Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #66 +/- ##
========================================
Coverage ? 0.00%
========================================
Files ? 7
Lines ? 331
Branches ? 0
========================================
Hits ? 0
Misses ? 331
Partials ? 0
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Two things worth a look before merging:
|
Thanks for the review!
|
|
Both addressed, thanks for the context on #499 — makes sense. Approving. |
irfanuddinahmad
left a comment
There was a problem hiding this comment.
Reviewed the modernization changes (uv/pyproject.toml migration, dependency completeness, CI config). Two follow-up points raised were addressed in comments — good to merge.
feanil
left a comment
There was a problem hiding this comment.
Looks like there are quite a few small gotchas in this migration, we should make sure we don't run into the same issues in other code. LLMs won't catch these opinion things so be sure to review your PRs manually in the future.
| fail-fast: false | ||
| matrix: | ||
| python-version: ["3.12"] | ||
| toxenv: [lint, py312] |
There was a problem hiding this comment.
| toxenv: [lint, py312] | |
| toxenv: [lint, py] |
If you set the toxenv to py it will run with the default system interpreter which is determined by the python-version setting above. This is a bit more resilient. For example, when we add python3.14 to the python-version matrix. We won't need to also update the toxenv row. And we won't get in a situation where it tries to run the python 3.12 tests in the python 3.14 environment.
There was a problem hiding this comment.
Thanks! I thought explicitly naming py312 would be better for supporting multiple versions, but now I get it — adding to python-version: ["3.12", "3.14"] handles all combinations automatically with py.
Applied suggestion in commit, please review the updated coverage upload if condition
There was a problem hiding this comment.
Removed — no codecov.yml existed on master before this PR and configuring Codecov behavior is out of scope here.
I had added it as a placeholder to populate later, but that's better tracked separately if needed.
|
|
||
| quality: quality-python ## Run linters | ||
|
|
||
| lint: quality ## Run linting checks (alias for quality) |
There was a problem hiding this comment.
I don't remember us deciding that we want to change the default target for this from quality to lint. Where was this decided? quality is the common name for this in our ecosystem so I'm reluctant to add a new alias that could lead to confusion.
There was a problem hiding this comment.
Agreed, we should follow a single standard, and quality is the right choice. I've removed the lint alias.
Fixed in: efd6cf5
Learning: The AI tried to imitate things from other repos from memory perhaps. AI guardrails and thorough human review is the need
|
|
||
| test-python: clean ## run tests using pytest and generate coverage report | ||
| pytest | ||
| uv run tox -e py312 |
There was a problem hiding this comment.
We want this to not necessarily invoke tox. Tox is the underlying test framework for CI, but the make targets should just run the tests in the environment they exist in.
| uv run tox -e py312 | |
| uv run pytest |
There was a problem hiding this comment.
This came from the discussion in xblocks-extra#38
I interpreted that as make test-python → tox.
Should we take uv run pytest as the preferred direction?
Should we don't call any tox environment from make file For example tox -e quality?
There was a problem hiding this comment.
Ah, got it thanks, seeing it in practice here, I am noticing that one of the issues with this is that we hardcode which python version the test runs in the makefile. So to test on a new python version you'll need to add that version to tox and then run tox directly to test with the new vesion. I think this is fine. Neither of the two flows is great but since we decided this one, we can leave this as is. Thanks for the pointer and reminder.
|
|
||
| [project] | ||
| name = "mockprock" | ||
| version = "2.0.0" |
There was a problem hiding this comment.
this shouldn't be in here right? It should be determined by semantic release?
There was a problem hiding this comment.
mockprock isn't published to PyPI, so we're using static versioning here. The 2.0.0 value is carried over from setup.py on master — no semantic-release setup is planned for this repo.
| # Runtime deps needed for pylint to resolve imports | ||
| "requests", | ||
| "Flask<2.0", | ||
| "PyJWT", | ||
| "edx-proctoring", |
There was a problem hiding this comment.
This should be an include-group of the base dependencies.
There was a problem hiding this comment.
To keep the dependencies in parity with master branch I have removed them from the quality group they were added defensively without need.
7b021da
| envlist = py312, lint | ||
| requires = tox-uv>=1 | ||
|
|
||
| [testenv:lint] |
There was a problem hiding this comment.
This should just be quality adding an extra alias is not helpful.
1194d33 to
ca6999c
Compare
Using `py` defers to the active interpreter set by `actions/setup-python`, so adding new Python versions to the matrix works without also updating toxenv. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
No codecov.yml existed on master before this PR and configuring Codecov behavior is out of scope for this modernization story. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
`quality` is the established standard across the Open edX ecosystem. The `lint` alias was unnecessary and potentially confusing. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
`quality` is the established standard across the Open edX ecosystem. Updated tox.ini, Makefile, and CI matrix accordingly. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Pylint resolves imports fine without Flask, PyJWT, requests, and edx-proctoring — no import errors occur. These deps were added defensively but are not needed. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
ca6999c to
7b021da
Compare
feanil
left a comment
There was a problem hiding this comment.
Two non-blocking comments, thanks for addressing the rest, this looks good to go I think.
There was a problem hiding this comment.
Just noticed that this is a python package but it's only being released to NPM? Not a blocker for this PR but making a note that this is strange.
|
|
||
| test-python: clean ## run tests using pytest and generate coverage report | ||
| pytest | ||
| uv run tox -e py312 |
There was a problem hiding this comment.
Ah, got it thanks, seeing it in practice here, I am noticing that one of the issues with this is that we hardcode which python version the test runs in the makefile. So to test on a new python version you'll need to add that version to tox and then run tox directly to test with the new vesion. I think this is fine. Neither of the two flows is great but since we decided this one, we can leave this as is. Thanks for the pointer and reminder.
Important
PR implemented with the assistance of Claude Code, human-reviewed and improved before pushing to code review.
Summary
Modernize
mockprockto uv + pyproject.toml (PEP 621/735).Part of openedx/public-engineering#506.
Split out of #65; ruff retained there for adoption in a future epic (per public-engineering#506).
setup.pywithpyproject.toml(PEP 621 static metadata)uvwith PEP 735 dependency groups; commituv.lockpyproject.tomltox.inito usetox-uvwithuv-venv-lock-runnerastral-sh/setup-uv; SHA-pin all actions; addworkflow_calltriggerrequires-python = ">=3.12"Removed
Deleted files:
setup.py,pytest.ini,requirements/Removed Makefile targets:
$(COMMON_CONSTRAINTS_TXT)common_constraints.txtdownload; constraints now managed byedx_lint write_uv_constraints+uv lockPython 3.11 dropped
Python 3.11 reached end-of-life in October 2024 and Open edX dropped it platform-wide. Removed from the tox envlist, CI matrix, and classifiers. The new minimum is Python 3.12.
Not included/implemented
release.yml/python-semantic-release— master had no PyPI publish workflow (the existingrelease.ymlis an npm/Node.js semantic-release pipeline; it was updated only to add a CI gating job before release).src/layout — the package remains at the top-levelmockprock/path; a separate follow-up PR can perform the layout move once the tooling migration is stable.Versioning
[Static]
version = "2.0.0"carried over fromsetup.pyon master — master had no PyPI publish workflow, sosetuptools-scmis 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:
pylintrcis retained exactly as on master — ruff is out of scope this cycle and pylint remains the active linter.server.py:from collections import Iterablewas replaced withfrom collections.abc import Iterable—collections.Iterablewas removed in Python 3.12 and this is required for the new minimum Python version.release.yml(npm/Node.js semantic-release) was updated to add arun_testsjob that gates the release on CI passing; no python-semantic-release is introduced.commands.py,db.py,desktop_views.py,rest_api_client/client.py) was fixed to satisfy isort — these are mechanical, no logic change.rest_api_client/subpackage andtemplates/are now correctly included in the distribution; master'ssetup.pylisted onlypackages=['mockprock']and omitted them.🤖 Generated with Claude Code