Skip to content

feat: modernize mockprock to uv + pyproject.toml (pylint retained, no ruff) - #66

Merged
kdmccormick merged 11 commits into
openedx:masterfrom
farhan:farhan/modernize-python-repo
Jul 23, 2026
Merged

feat: modernize mockprock to uv + pyproject.toml (pylint retained, no ruff)#66
kdmccormick merged 11 commits into
openedx:masterfrom
farhan:farhan/modernize-python-repo

Conversation

@farhan

@farhan farhan commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Important

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

Summary

Modernize mockprock to 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).

  • 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 its own epic per #506); coverage config moved into pyproject.toml
  • Update tox.ini to use tox-uv with uv-venv-lock-runner
  • Update CI to use 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 (mockprock has no existing tests)

Removed

Deleted files: setup.py, pytest.ini, requirements/

Removed Makefile targets:

Target Reason
$(COMMON_CONSTRAINTS_TXT) Removed the wget-based common_constraints.txt download; constraints now managed by edx_lint write_uv_constraints + uv lock

Python 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 existing release.yml is 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-level mockprock/ 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 from setup.py on master — 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:

  • pylintrc is retained exactly as on master — ruff is out of scope this cycle and pylint remains the active linter.
  • server.py: from collections import Iterable was replaced with from collections.abc import Iterablecollections.Iterable was removed in Python 3.12 and this is required for the new minimum Python version.
  • The existing release.yml (npm/Node.js semantic-release) was updated to add a run_tests job that gates the release on CI passing; no python-semantic-release is introduced.
  • Import ordering in several files (commands.py, db.py, desktop_views.py, rest_api_client/client.py) was fixed to satisfy isort — these are mechanical, no logic change.
  • The rest_api_client/ subpackage and templates/ are now correctly included in the distribution; master's setup.py listed only packages=['mockprock'] and omitted them.

🤖 Generated with Claude Code

…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>
farhan and others added 2 commits July 16, 2026 16:08
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>
@farhan
farhan force-pushed the farhan/modernize-python-repo branch from 76ea37a to ce47314 Compare July 16, 2026 11:47
- 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

codecov Bot commented Jul 16, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 5 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (master@695a0a3). Learn more about missing BASE report.

Files with missing lines Patch % Lines
mockprock/db.py 0.00% 2 Missing ⚠️
mockprock/server.py 0.00% 2 Missing ⚠️
mockprock/desktop_views.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##             master     #66   +/-   ##
========================================
  Coverage          ?   0.00%           
========================================
  Files             ?       7           
  Lines             ?     331           
  Branches          ?       0           
========================================
  Hits              ?       0           
  Misses            ?     331           
  Partials          ?       0           
Flag Coverage Δ
unittests 0.00% <0.00%> (?)

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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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

Copy link
Copy Markdown
Contributor

Two things worth a look before merging:

  1. pylint is non-blocking: tox.ini's lint env runs pylint with --exit-zero, so it can never fail CI regardless of findings — only isort --check-only actually gates. Intentional per the commit message (pre-existing debt shouldn't block this PR), but worth a follow-up ticket to burn down the debt and make it a real gate.
  2. requires-python = ">=3.12" drops 3.11 support — worth confirming nothing else still pins against 3.11 against this package (e.g. edx-proctoring's own CI matrix, since mockprock looks like its test double), since bumping the floor here could break a consumer's CI on next upgrade.

@farhan

farhan commented Jul 17, 2026

Copy link
Copy Markdown
Contributor Author

Two things worth a look before merging:

  1. pylint is non-blocking: tox.ini's lint env runs pylint with --exit-zero, so it can never fail CI regardless of findings — only isort --check-only actually gates. Intentional per the commit message (pre-existing debt shouldn't block this PR), but worth a follow-up ticket to burn down the debt and make it a real gate.
  2. requires-python = ">=3.12" drops 3.11 support — worth confirming nothing else still pins against 3.11 against this package (e.g. edx-proctoring's own CI matrix, since mockprock looks like its test double), since bumping the floor here could break a consumer's CI on next upgrade.

Thanks for the review!

  1. pylint --exit-zero — agreed, A follow-up ticket make sense.
  2. Python 3.11 drop — We have dropped the support of py3.11 from all python repos in this epic. It seems mockprock was simply missed from that epic's tracking list; this PR closes that gap.

@farhan
farhan requested a review from irfanuddinahmad July 17, 2026 15:26
@irfanuddinahmad

Copy link
Copy Markdown
Contributor

Both addressed, thanks for the context on #499 — makes sense. Approving.

@irfanuddinahmad irfanuddinahmad left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed the modernization changes (uv/pyproject.toml migration, dependency completeness, CI config). Two follow-up points raised were addressed in comments — good to merge.

@farhan farhan self-assigned this Jul 21, 2026
@farhan farhan moved this to 🏗 In progress in Aximprovements Team Jul 21, 2026
@farhan farhan moved this from 🏗 In progress to 👀 In review in Aximprovements Team Jul 21, 2026

@feanil feanil left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Comment thread .github/workflows/ci.yml Outdated
fail-fast: false
matrix:
python-version: ["3.12"]
toxenv: [lint, py312]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
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.

@farhan farhan Jul 22, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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

Comment thread codecov.yml Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why add this empty file?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

Comment thread Makefile Outdated

quality: quality-python ## Run linters

lint: quality ## Run linting checks (alias for quality)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

@farhan farhan Jul 22, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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

Comment thread Makefile

test-python: clean ## run tests using pytest and generate coverage report
pytest
uv run tox -e py312

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Suggested change
uv run tox -e py312
uv run pytest

@farhan farhan Jul 22, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This came from the discussion in xblocks-extra#38

I interpreted that as make test-pythontox.

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?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Comment thread pyproject.toml

[project]
name = "mockprock"
version = "2.0.0"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this shouldn't be in here right? It should be determined by semantic release?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

Comment thread pyproject.toml Outdated
Comment on lines +70 to +74
# Runtime deps needed for pylint to resolve imports
"requests",
"Flask<2.0",
"PyJWT",
"edx-proctoring",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This should be an include-group of the base dependencies.

@farhan farhan Jul 22, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

To keep the dependencies in parity with master branch I have removed them from the quality group they were added defensively without need.
7b021da

Comment thread tox.ini Outdated
envlist = py312, lint
requires = tox-uv>=1

[testenv:lint]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This should just be quality adding an extra alias is not helpful.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

👍 fixed: acdda70

@farhan
farhan force-pushed the farhan/modernize-python-repo branch 2 times, most recently from 1194d33 to ca6999c Compare July 22, 2026 16:37
farhan and others added 5 commits July 22, 2026 21:40
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>
@farhan
farhan force-pushed the farhan/modernize-python-repo branch from ca6999c to 7b021da Compare July 22, 2026 16:41
@farhan
farhan requested a review from feanil July 22, 2026 16:48

@feanil feanil left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Two non-blocking comments, thanks for addressing the rest, this looks good to go I think.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Comment thread Makefile

test-python: clean ## run tests using pytest and generate coverage report
pytest
uv run tox -e py312

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

@kdmccormick
kdmccormick merged commit 7d870be into openedx:master Jul 23, 2026
5 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.

5 participants