Modernize python tooling#282
Conversation
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Thanks for the pull request, @salman2013! This repository is currently maintained by Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review. 🔘 Get product approvalIf you haven't already, check this list to see if your contribution needs to go through the product review process.
🔘 Provide contextTo help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:
🔘 Get a green buildIf one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green. DetailsWhere can I find more information?If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources: When can I expect my changes to be merged?Our goal is to get community contributions seen and reviewed as efficiently as possible. However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:
💡 As a result it may take up to several weeks or months to complete a review and merge your PR. |
ci.yml was not present before this migration; removing it to avoid introducing new checks. release.yml runs semantic-release directly on push to master without a prior test gate. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
👋 Reviewed this against the same checklist we've been applying across the modernization effort (openedx/public-engineering#506/#511). One real pre-merge blocker and one shared issue: 1. Missing git tag for the actual latest published version. PyPI shows 2. |
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
57d2474 to
ba46de2
Compare
There was a problem hiding this comment.
Missing tox.ini — The migration requires adding tox.ini when absent. Master lacked it too,
Furhter: this migration is the required moment to add it (with requires = tox-uv>=1, runner = uv-venv-lock-runner, dependency_groups =, and a quality env for pylint). Without it uv run tox cannot be used in CI or locally.
Nice to have:
Missing minimal codecov.yml — The migration skill requires adding a minimal codecov.yml
| jobs: | ||
| run_tests: | ||
| uses: ./.github/workflows/ci.yml | ||
| secrets: inherit |
There was a problem hiding this comment.
ci.yml does not exist on this branch or on master.
We ought to add ci to run the tests.
| - name: Upload dist artifacts | ||
| if: steps.release.outputs.released == 'true' | ||
| uses: actions/upload-artifact@v4 | ||
| with: |
There was a problem hiding this comment.
actions/upload-artifact@v4 is not SHA-pinned. All other actions in this file use immutable commit SHAs; this one should too.
Resolve the current SHA:
gh api repos/actions/upload-artifact/git/refs/tags/v4 --jq '.object.sha'
Then use: uses: actions/upload-artifact@<sha> # v4
| steps: | ||
| - name: Download dist artifacts | ||
| uses: actions/download-artifact@v4 | ||
| with: |
There was a problem hiding this comment.
actions/download-artifact@v4 is not SHA-pinned. Same fix as upload-artifact above.
gh api repos/actions/download-artifact/git/refs/tags/v4 --jq '.object.sha'
| @@ -0,0 +1,101 @@ | |||
| [build-system] | |||
| requires = ["setuptools>=64", "setuptools-scm>=8.0"] | |||
| build-backend = "setuptools.build_meta" | |||
There was a problem hiding this comment.
setuptools>=64
same we had a discussion on it.
Not a blocker
| license-files = ["LICENSE.TXT"] | ||
| authors = [{name = "edX", email = "oscm@edx.org"}] | ||
| classifiers = [ | ||
| "Development Status :: 4 - Beta", |
There was a problem hiding this comment.
Missing Django framework classifiers and AGPL trove classifier. setup.py on master included 'License :: OSI Approved :: GNU Affero General Public License v3'; omitting it is a PyPI metadata regression.
Add after the existing classifiers:
"License :: OSI Approved :: GNU Affero General Public License v3",
"Framework :: Django",
"Framework :: Django :: 4.2",
"Framework :: Django :: 5.2",| "Natural Language :: English", | ||
| "Programming Language :: Python :: 3", | ||
| "Programming Language :: Python :: 3.11", | ||
| "Programming Language :: Python :: 3.12", |
There was a problem hiding this comment.
Python 3.11 should be dropped — the migration target is requires-python = ">=3.12". Python 3.11 reached end-of-life in October 2024 and is removed org-wide in this cycle.
Remove this classifier and update requires-python to ">=3.12" on the following line.
| from .acid import AcidBlock, AcidParentBlock, AcidAside | ||
|
|
||
| from importlib.metadata import version | ||
| __version__ = version("acid-xblock") |
There was a problem hiding this comment.
Two issues with __version__:
-
Import ordering —
C0411: wrong-import-order: stdlib import (importlib.metadata) placed after a local import (from .acid import ...). This is a new pylint regression not present on master;make qualityexits 21. Move the stdlib import to line 1. -
Missing fallback — Without
except PackageNotFoundError,import acidon an uninstalled checkout raisesAttributeError. Add:
from importlib.metadata import version, PackageNotFoundError
from .acid import AcidBlock, AcidParentBlock, AcidAside
try:
__version__ = version("acid-xblock")
except PackageNotFoundError:
__version__ = "0.0.0"| quality-python: ## Run python linters | ||
| pylint --rcfile=pylintrc acid setup.py | ||
| uv run pylint --rcfile=pylintrc acid | ||
|
|
There was a problem hiding this comment.
@claude suggestion:
After the src/ layout migration, pylint is still passed acid (the old top-level path) rather than src/acid. It resolves correctly today because the package is installed in editable mode, but passing the explicit source path is clearer and consistent with other migrated repos.
Consider: uv run pylint --rcfile=pylintrc src/acid
|
|
||
| [tool.coverage.run] | ||
| branch = true | ||
| source = ["acid"] |
There was a problem hiding this comment.
@claude suggested
For a src/-layout package, source_pkgs = ["acid"] is preferred over source = ["acid"]. source_pkgs tells coverage to locate the package via import (finding it under src/) rather than by filesystem path, which avoids measuring the wrong copy when both an editable install and a source directory exist.
Modernizes the Python tooling for this repo in three phases, aligning with the Open edX org standard established in openedx/sample-plugin.
Ticket: openedx/public-engineering#511
Parent ticket: openedx/public-engineering#506
Changes generated by Claude Sonnet 4.6 using the modernize-python-tooling skill, reviewed by a human.