Skip to content

feat: modernize Python tooling (pyproject.toml + uv) - #1015

Merged
feanil merged 25 commits into
mainfrom
irfanuddinahmad/uv-migration
Nov 3, 2026
Merged

feanil merged 25 commits into
mainfrom
irfanuddinahmad/uv-migration

Conversation

@irfanuddinahmad

@irfanuddinahmad irfanuddinahmad commented Jul 9, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Modernizes this repo's Python tooling per the org-wide standardization tracked in openedx/public-engineering#513 (and the parent openedx/public-engineering#506):

  • Consolidate tool config into pyproject.toml, replacing setup.cfg. This is a deployed Django service, not a published package, so [project] is minimal (name/version/requires-python only, no PyPI packaging metadata) and no semantic-release is added.
  • Switch dependency management from pip-compile to uv: requirements/*.in+*.txt are replaced by PEP 735 [dependency-groups] + a single uv.lock. Since there's no [project.dependencies] list, runtime deps live in an explicit base group that test/quality/doc/production/dev all compose via {include-group = "base"}.
  • Update tox.ini/Makefile to use tox-uv's uv-venv-lock-runner, and switch CI (including upgrade-python-requirements.yml, which calls make upgrade directly rather than the shared reusable workflow) to install uv and run via uv sync/uv run tox.

Part of openedx/public-engineering#513.

Test plan

  • uv lock resolves cleanly (204 packages)
  • Could not fully verify uv sync/uv run tox on my machine (no libmysqlclient/pkg-config locally to build mysqlclient from source) -- CI's ubuntu-latest runners have these preinstalled, so this needs verifying there.

Action needed: required status checks

This PR renames the tests job's matrix values (tests (3.12, pinned) / tests (3.12, 5.2) → tests (3.12, django42) / tests (3.12, django52)). If this repo's required-status-checks list (Settings → Branches) references the old names, those checks will show as "Expected — Waiting for status to be reported" indefinitely and block merging, even though the renamed jobs are green. Needs someone with repo admin access to update the required-status-checks list to the new job names — I don't have admin rights here to check or fix it directly.

🤖 Generated with Claude Code

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Jul 9, 2026
@openedx-webhooks

Copy link
Copy Markdown

Thanks for the pull request, @irfanuddinahmad!

This repository is currently maintained by @openedx/2u-enterprise.

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 approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.
🔘 Provide context

To 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:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads
🔘 Get a green build

If one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green.

Details
Where 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:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

💡 As a result it may take up to several weeks or months to complete a review and merge your PR.

@openedx-webhooks openedx-webhooks added the core contributor PR author is a Core Contributor (who may or may not have write access to this repo). label Jul 9, 2026
@github-project-automation github-project-automation Bot moved this to Needs Triage in Contributions Jul 9, 2026
@mphilbrick211 mphilbrick211 moved this from Needs Triage to Ready for Review in Contributions Jul 13, 2026
@mphilbrick211
mphilbrick211 requested a review from a team July 13, 2026 15:54
Irfan Ahmad and others added 7 commits July 15, 2026 09:13
Move isort/pytest settings from setup.cfg/pytest.ini into pyproject.toml.
enterprise-access is a deployed Django service, not a published package, so
no [build-system]/packaging metadata is added here. Also drop the now-dead
[pytest] section from tox.ini (pytest.ini took precedence over it already).
flake8 config from setup.cfg is dropped since flake8 isn't invoked anywhere
in this repo's Makefile or CI.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Replace requirements/*.in + *.txt with PEP 735 dependency-groups in
pyproject.toml and a single uv.lock. Since this repo has no [project]
packaging metadata, runtime deps live in an explicit `base` group that
test/quality/doc/production/dev all compose via {include-group = "base"}
(quality and doc compose {include-group = "test"} directly, mirroring
this repo's own requirements/quality.in and doc.in which built on top of
test.txt rather than base.txt). Wire the existing tox.ini up to
uv-venv-lock-runner with per-env dependency_groups, update the Makefile's
requirements targets to their uv equivalents, and switch CI to install uv
and run tests via `uv run tox`. Also add an uv install step to the
scheduled requirements-upgrade workflow so `make upgrade` keeps working.

Note: could not fully verify `uv sync`/`uv run tox` locally on this
machine (no libmysqlclient/pkg-config for building mysqlclient from
source) -- `uv lock` resolves cleanly; full sync needs verifying via CI.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
The comment said "Disable pylint import error because we don't install
django-debug-toolbar for CI build" but the actual # pylint: disable
pragma was never added. This was previously masked because the old CI
ran the quality checks inside the broader dev-dependency environment
(which does include django-debug-toolbar); the new tox quality env is
correctly scoped to just the quality group, which doesn't include it,
exposing the missing pragma.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Every uv sync/uv run invocation in this repo names an explicit --group,
but uv's implicit default group (named "dev") was still being synced
alongside it, silently pulling the entire dev/test/quality/ci superset
(and mysqlclient) into every target. Verified: `uv sync --group ci`
previously failed trying to build mysqlclient "because
enterprise-access:dev depends on mysqlclient"; with default-groups = []
it now installs only the ci group's own tools.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
This migration's ci.yml is the first time pylint actually runs in CI for
this repo -- the old ci.yml called `make style isort_check pii_check
check_keywords` directly, bypassing tox.ini's pre-existing (but dormant)
`quality` env entirely. Turning it on surfaced real, previously-invisible
findings across the app:

- Unused imports (customer_billing.py, test_api.py, test_checkout_intent_views.py,
  test_enrollment_deadline_strategies.py).
- Deliberate lazy imports used to avoid circular imports (utils.py,
  enrollment_deadline_strategies.py) that were missing their
  pylint-disable annotations.
- A redundant `pass` after a logged except block.
- A missing docstring (stripe_event_handlers.py).
- `staff_user = self.create_user(...)` in two tests: create_user() has no
  return value (it sets self.user as a side effect), so this always
  assigned None; set_jwt_cookie's user=None already falls back to
  self.user, so behavior is unchanged, but the dead assignment is removed.
- A mutable default argument (`roles_and_contexts=[]`) in test_utils.
- cyclic-import (R0401) between utils.py and enrollment_deadline_strategies.py:
  the two modules are legitimately mutually dependent and already broken
  via deferred imports, so disabled via pylintrc_tweaks like the other
  intentional suppressions already there.

Verified: pylint/pycodestyle/isort all pass; ran the 4 touched test
modules directly (136 passed).

Co-Authored-By: Claude Sonnet 5 <[email protected]>
… gate

Same root cause as the preceding pylint fix: pydocstyle runs immediately
after pylint in tox.ini's quality env, which this migration is the first
to actually wire into CI. ~40 pre-existing findings (missing docstrings,
non-imperative wording, D205/D400/D415 summary-line formatting) across
utils.py, tasks.py, cache_utils.py, celery.py, and __init__.py were never
previously checked. Purely docstring wording/formatting -- no behavior
changes. Verified: pydocstyle/pylint/pycodestyle/isort all pass; full
test suite (1243 tests) passes.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
The uv migration's unpinned "stripe" dependency resolved to the latest
15.3.0 at lock time, silently upgrading from the 14.1.0 that master's
pip-compiled requirements/test.txt pins. stripe 15.x changed StripeObject's
attribute/item access behavior in a way that breaks this app's `.get()`
calls on nested event payloads -- confirmed via the actual CI logs for
this PR's "tests" jobs (KeyError/AttributeError in stripe/_stripe_object.py),
and reproduced/fixed locally: 51 failing tests across customer_billing
and provisioning all pass again once stripe is constrained back to <15.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@irfanuddinahmad
irfanuddinahmad force-pushed the irfanuddinahmad/uv-migration branch from f3fd404 to de63148 Compare July 15, 2026 04:14
@farhan
farhan self-requested a review July 16, 2026 11:39
@farhan

farhan commented Jul 16, 2026

Copy link
Copy Markdown

Important

Written with the assistance of Claude Code, human-reviewed before posting.


Must Fix

  1. Makefile bare tool invocations
    make lint, make test, make style, make isort_check invoke pylint, pytest, pycodestyle, isort directly without uv run. These fail on a clean checkout where only uv is installed. Prefix each with uv run or delegate to uv run tox -e quality/unittests.

  2. Stale .coveragerc
    .coveragerc is still on disk and its contents have not been migrated to pyproject.toml — the file has no [tool.coverage] section at all. Migrate and delete the old file.

  3. Redundant actions/setup-python
    ci.yml uses both actions/setup-python and astral-sh/setup-uv in all jobs. Target state is setup-uv only (it handles Python installation via its python-version input). Remove actions/setup-python from all jobs.

  4. __version__ still in source
    enterprise_access/__init__.py still declares __version__ = '1.0.1', and it is actively imported in enterprise_access/cache_utils.py (from enterprise_access import __version__ as code_version). Remove __version__ from __init__.py and update cache_utils.py to use importlib.metadata.version("enterprise-access") or a hard-coded string.

  5. Static version mismatch
    pyproject.toml has version = "0.1.0" but master's __version__ is "1.0.1". Change to version = "1.0.1".


We should decide on:

  1. Branch protection check names
    Old CI produced a check named tests (3.12, pinned). New CI produces tests (py312-django42), tests (py312-django52), tests (translations). If the old name is a required status check in branch protection, all future PRs will be blocked. This cannot be verified without admin access — must be confirmed before merging. tests (3.12, pinned) is failing on this PR because of this reason I believe.

  2. src/ layout not adopted
    enterprise_access/ remains at repo root. We should decide whether to accept the non-adoption for this Django service.

  3. Minimal [project] metadata
    [project] contains only name, version, requires-python. Missing: description, readme, license, authors, classifiers, urls, dependencies. We needs to decided either its alright for a django service.


Informational

@claude says following, please verify:

This PR includes some non-migration source changes alongside the tooling migration: enterprise_access/utils.py has notable modifications, and several other source files (celery.py, tasks.py, urls.py, cache_utils.py, customer_billing/stripe_event_handlers.py) were touched beyond what the migration requires.

@irfanuddinahmad

Copy link
Copy Markdown
Contributor Author

Re: the informational note about non-migration source changes — verified this in detail:

This is isolated to enterprise-access; I checked all 10 repos in the modernization effort and none of the others have source-level lint fixes, only tooling/config changes.

Root cause: enterprise-access's old CI called make style isort_check pii_check check_keywords directly, which never actually ran pylint or pydocstyle — they were configured in tox.ini's quality env but that env was never wired into CI. This migration switches CI to uv run tox, which runs that env for the first time and surfaced pre-existing debt across the app: missing/non-imperative docstrings, two unused imports, one redundant pass after a logger call, one mutable default arg, and a few missing pylint-disable annotations. Without fixing it, CI would be permanently red on this PR since the debt predates it but the gate is newly active here.

Verified each change individually (diffed against master) — all behavior-preserving. Happy to point to the exact commits (1ab7bc1, 1ed7a71) if useful, each scoped separately from the tooling-migration commits with a full rationale in the message.

@farhan

farhan commented Jul 17, 2026

Copy link
Copy Markdown

tests are not running

@farhan farhan left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thanks for the detailed explanation on the source-level lint fixes — the justification makes sense given the previously unexercised CI gate.

The Must Fix items from the earlier review still need to be addressed. I am pinning them inline now.

One change request is related to a file not touched by this PR but I believe should cover within this PR:

Change request:

.coveragerc (not in diff): The file still exists on disk with its original [run] section. I think its contents (branch, data_file, source, omit) should be migrated to [tool.coverage.run] in pyproject.toml and the file deleted. Currently pyproject.toml has no [tool.coverage] section at all. For reference, this has already been done in xblocks-extra — it includes [tool.coverage.run], [tool.coverage.report], and [tool.coverage.html] sections.

Comment thread Makefile Resolved
Comment thread .github/workflows/ci.yml Resolved
Comment thread .github/workflows/ci.yml Resolved
Comment thread .github/workflows/ci.yml Resolved
Comment thread pyproject.toml Resolved
Comment thread enterprise_access/__init__.py Resolved
Comment thread enterprise_access/cache_utils.py Resolved
Addresses farhan's review on #1015:

- Makefile: prefix uv run on all bare tool invocations (test,
  isort_check, style, lint, plus coverage and isort which have the same
  gap) -- these fail on a clean checkout where only uv is installed
- ci.yml: remove actions/setup-python from both the tests and quality
  jobs (redundant once astral-sh/setup-uv gets python-version) and add
  enable-cache/python-version to setup-uv
- enterprise_access/__init__.py: remove __version__ -- this repo is a
  deployed service (pyproject.toml's [tool.uv] package = false), not an
  installed package, and has no python-semantic-release/release.yml, so
  a hardcoded version string here was just stale (0.1.0 vs master's 1.0.1)
- enterprise_access/cache_utils.py: replace the __version__ import
  (which would now break) with a hardcoded code_version constant --
  importlib.metadata.version() doesn't work here since package = false
  means this project is never actually installed with dist-info metadata
- pyproject.toml: sync version to 1.0.1 to match master's actual
  __version__; migrate .coveragerc into [tool.coverage.run] and delete
  the old file

Branch protection concern (renamed CI check names) is moot: verified via
gh api that openedx/enterprise-access's main branch has no branch
protection rules or rulesets configured at all, so there's no required
status check to break.

Verified: pyproject.toml parses, both edited .py files compile, no other
callers of the removed __version__ import (grepped the whole repo). Could
not run the full tox matrix locally -- same mysqlclient build environment
limitation already documented in the original PR.
@irfanuddinahmad

Copy link
Copy Markdown
Contributor Author

Addressed the Must-Fix items (Makefile `uv run` prefixes, `.coveragerc` migration, version sync to 1.0.1, `version`/`cache_utils.py` removal) and the redundant `actions/setup-python` steps.

On the branch protection concern: checked via `gh api repos/openedx/enterprise-access/branches/main/protection` and `.../rulesets` — both return empty/404. There's no branch protection or ruleset configured on `main` at all, so the renamed CI check names can't break anything here.

One thing worth a second look: `cache_utils.py`'s `code_version` can't use `importlib.metadata.version()` since this repo's `[tool.uv] package = false` means it's never actually installed with dist-info metadata — went with a hardcoded string synced to the new `1.0.1`, with a comment explaining why (and that it needs manual bumping going forward, since there's no semantic-release here).

@farhan

farhan commented Jul 27, 2026

Copy link
Copy Markdown

Addressed all review comments. Since I do not have push access to the openedx repo, the fix commits are on a fork branch at https://github.com/farhan/enterprise-access/tree/irfanuddinahmad/uv-migration — @irfanuddinahmad please cherry-pick or apply the 4 commits from there.

Summary of fixes:

  • Removed actions/setup-python from both tests and quality CI jobs (redundant with astral-sh/setup-uv): 2c32f2b
  • Added uv run prefix to all bare pytest/isort/pycodestyle/pylint calls in Makefile: 3b4cd69
  • Fixed version from 0.1.0 to 1.0.1 in pyproject.toml; migrated .coveragerc to [tool.coverage.run] in pyproject.toml and deleted the file: 03bc3b6
  • Removed __version__ from enterprise_access/__init__.py; replaced the from enterprise_access import __version__ as code_version import in cache_utils.py with a hardcoded code_version = '1.0.1' (importlib.metadata is not viable since package = false): 10d8fe3

The branch protection concern (check name change from tests (3.12, pinned) to tests (py312-django*)) is not a code change — a repo admin needs to update branch protection rules before merging.

Comment thread pylintrc Resolved
Comment thread pylintrc_tweaks Resolved
Comment thread pyproject.toml Resolved
Comment thread .github/workflows/ci.yml Resolved
Irfan Ahmad and others added 5 commits July 28, 2026 16:04
enterprise-access is a deployed Django service (`[tool.uv] package =
false`), never published to PyPI, so twine (a PyPI-publishing tool) has
no consumer here -- it was inherited from a shared template. Removing
it also drops its PyPI-publish-only transitive deps (rich, keyring,
secretstorage, jeepney, jaraco-*, markdown-it-py, mdurl,
more-itertools, id, pywin32-ctypes, requests-toolbelt, rfc3986) from
uv.lock.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
…workflow

astral-sh/setup-uv already provisions Python via its python-version
input, making the separate actions/setup-python step redundant.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
The condition only checked matrix.toxenv, with no python-version pin.
If a second Python version is ever added to the tests matrix, Codecov
would upload for every py312-django* variant across both Python
versions. Add python-version as an explicit matrix dimension and gate
the Codecov step on it.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
cyclic-import (R0401) was disabled globally in pylintrc/pylintrc_tweaks,
which would silently hide any future circular-import regression
anywhere in the codebase -- not just the one legitimate case.

The only real cycle is between enterprise_access/utils.py and
enterprise_access/apps/content_assignments/enrollment_deadline_strategies.py,
both already broken via deferred (function-local) imports. Pylint's
cyclic-import check excludes a module-to-module edge from its cycle
graph if cyclic-import is disabled at the specific import statement's
line (see pylint's ImportsChecker._add_imported_module), so adding
`# pylint: disable=cyclic-import` at the three deferred import sites
that form this cycle is sufficient to suppress it there without
touching the global config. Regenerated pylintrc from pylintrc_tweaks
via `edx_lint write pylintrc`.

Verified: with the global disable removed and these three per-line
disables in place, `pylint enterprise_access test_utils manage.py`
(what CI's quality job actually runs) is clean -- no other cyclic
imports exist in the codebase that the global disable was masking.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
tox.ini's django42/django52 factors both synced the same `test`
dependency group (locked against the loose base "Django>=2.2" pin,
which resolves to 5.2.x) and then force-overrode just the Django
package version via `deps=`. Every other transitively-resolved
package -- django-crispy-forms, django-filter, social-auth-app-django,
social-auth-core, etc. -- stayed pinned to whatever uv resolved for
Django 5.2, even when running "against Django 4.2". This silently
masked real Django-4.2-incompatible dependency versions instead of
actually testing against them (same bug as enterprise-subsidy#441).

Fix, mirroring that PR's approach:
- Split `test` into a Django-agnostic `test-base` plus two real
  groups that each add their own Django pin: `test` (>=5.2,<6.0,
  the current default) and a new `django42` (>=4.2,<5.0).
- Declare `django42` as conflicting with `test`/`quality`/`doc`/`dev`
  in [tool.uv].conflicts so uv.lock can carry both resolutions at
  once without them clobbering each other.
- Point tox.ini's django42 factor at the new `django42` group instead
  of `test`, and drop the `deps=` overrides entirely.

Verified: `uv lock` now resolves genuinely different versions for
django-crispy-forms (2.5 vs 2.6), django-filter (25.1 vs 25.2), and
social-auth-app-django/social-auth-core between the two groups.
Manually synced each group and confirmed `import django;
django.VERSION` reports (4, 2, 30, ...) under `django42` and
(5, 2, 16, ...) under `test`, and ran the full test suite under both
(1243 passed each). Confirmed uv rejects syncing `test` and
`django42` together, per the conflicts declaration.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Both conflicts were the same "main re-added actions/setup-python, we
already replaced it with astral-sh/setup-uv" pattern seen across the other
repos in this migration effort -- kept our uv-based approach in both
ci.yml and upgrade-python-requirements.yml, adopted main's
actions/checkout bump to v7.0.1.

No uv pip usage found in this repo to fix separately; the django42/
django52 fork-resolution fix and other lessons-learned items were already
addressed in earlier commits on this branch (d7ebd16, b2c3f92, f7a6546,
6bd8356, 61b1e4b).
@mphilbrick211 mphilbrick211 moved this from Ready for Review to In Eng Review in Contributions Aug 19, 2026
@irfanuddinahmad

Copy link
Copy Markdown
Contributor Author

CI is green now — should have been a transient issue.

@farhan
farhan self-requested a review September 14, 2026 07:59

@farhan farhan left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

some changes are requested

__all__ = ('celery_app',)


__version__ = '1.0.1'

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

We shouldn't remove this version definition, pick it from the package
reference: https://github.com/openedx/sample-plugin/blob/main/backend-plugin-sample/src/openedx_plugin_sample/__init__.py#L7

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 repo has [tool.uv] package = false (it's a deployed service, not installed), so importlib.metadata.version() won't resolve here — nothing installs it. Went with your other suggestion instead (see next thread): restored __version__ in __init__.py and import it into cache_utils.py, fixed in be38b8e.

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.

Sample-plugin's importlib.metadata pattern needs the project actually installed as a package, but this repo has [tool.uv] package = false (deliberately -- it's a Django service, not installed). Verified: switching to it crashes on Django startup with PackageNotFoundError. Keeping the hardcoded string.

Comment thread enterprise_access/cache_utils.py Outdated
# This repo is a deployed service (pyproject.toml's [tool.uv] package = false),
# not an installed package, so importlib.metadata.version() has nothing to look
# up here. Bump this alongside pyproject.toml's version on release.
code_version = '1.0.1'

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I think we should keep the version to __init__.py and import that to here

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.

Done in be38b8e — restored __version__ in __init__.py and cache_utils.py now imports it, so there's one place to bump per release instead of two.

Comment thread tox.ini
-r{toxinidir}/requirements/test.txt
commands =
code_annotations django_find_annotations --config_file .pii_annotations.yml --lint --report --coverage
python manage.py check_reserved_keywords --override_file db_keyword_overrides.yml

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Why its added in scope of this PR?
is it intentional?

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.

Intentional. Old CI ran make style isort_check pii_check check_keywords directly, bypassing tox entirely. New CI only calls tox envs, so check_keywords's command needed a home — folded into the pii_check env since it was already grouped with it in the old Makefile invocation. Same checks as before, just consolidated.

# Import here to avoid circular import with enterprise_access.utils
from enterprise_access.utils import get_normalized_metadata_for_assignment
from enterprise_access.utils import \
get_normalized_metadata_for_assignment # pylint: disable=import-outside-toplevel,cyclic-import

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Why this indentation is needed?

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.

Needed because of the added # pylint: disable=import-outside-toplevel,cyclic-import — without it the line exceeds 120 chars. See 1ab7bc1: old CI never actually ran the quality tox env (bypassed it, same as the pii_check thread above), so pylint wasn't gating merges before. Turning it on surfaced this deliberate lazy-import missing its disable comment.

RETIRED_EMAIL_ADDRESS_FORMAT,
LearnerContentAssignmentStateChoices
)
from ..constants import NUM_DAYS_BEFORE_AUTO_EXPIRATION, LearnerContentAssignmentStateChoices

@farhan farhan Sep 15, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Earlier indentation was better, we needs to look into
What config change need it to happen?

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.

Same cause as the thread above (1ab7bc1) — RETIRED_EMAIL_ADDRESS_FORMAT was an unused import even pre-migration, just never caught because pylint wasn't running in CI. isort collapsed the remaining 2-name import to one line since it now fits under 120 chars.

Comment thread .github/workflows/ci.yml Outdated
python-version:
- "3.12"
toxenv:
- "py312-django42"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

We shouldn't add py312 at the start

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 in 0611d8e — dropped the py312 prefix, same as the fix on edx-enterprise-subsidy-client. tox.ini's dependency-group selection only keys off the django42/django52 factor, never py312, so it was purely decorative. Verified tox -e django42/-e django52 both still resolve to the right group and pass the full suite (1243 tests each).

Comment thread .github/workflows/ci.yml
strategy:
matrix:
python-version: ["3.12"]
django-version: ["pinned", "5.2"]

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Please check why these tests are not running
Is it because of change of pinned?
Image

@irfanuddinahmad irfanuddinahmad Sep 15, 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.

The toxenv values got renamed (now django42/django52/translations), so no job will ever produce that exact context string again. All 3 new jobs are green on the current head. This needs someone with repo admin rights to update the required-status-checks list under Settings → Branches to the new job names

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

These tests are not running, they should run, we should look into it
image

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.

Confirmed via the actual job logs (run 34980268393, current head 0611d8e): django42 and django52 both collected and ran 1243 tests each, all passed. If the screenshot was a codecov gap, that run also hit a Codecov 429 rate-limit on upload -- separate infra issue, not a test-collection problem.

irfanuddinahmad and others added 2 commits September 15, 2026 19:10
cache_utils.py's code_version was hardcoded as a duplicate string literal,
requiring manual sync with pyproject.toml's version on every release.
Restore __version__ in __init__.py (as it existed pre-migration) and
import it into cache_utils.py, so there's one place to bump per release
instead of two.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
tox.ini's [testenv] dependency-group selection keys only on the
django42/django52 factor, never on py312 - this repo only tests one
Python version, so the py312- prefix on each toxenv value was purely
decorative. Same pattern already fixed on edx-enterprise-subsidy-client
for the same reason.

Verified both renamed envs still resolve to the correct dependency group
and pass the full suite (uv run tox -e django42 / -e django52, 1243
tests each).

Co-Authored-By: Claude Sonnet 5 <[email protected]>

@farhan farhan left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM!

irfanuddinahmad and others added 3 commits September 24, 2026 16:18
Makefile now assumes an already-synced/activated local env; uv run
stays in CI workflow steps only. See openedx-unsupported/ccx-keys#190 (review
comment r4097501942).

Co-Authored-By: Claude Sonnet 5 <[email protected]>
The `dev` group omitted `{include-group = "doc"}`, so `make requirements`
(`uv sync --group dev`) never provisioned doc8/Sphinx and `make docs`
failed on a fresh clone. Matches the pattern already used in
openedx/edx-enterprise's pyproject.toml.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@farhan

farhan commented Oct 1, 2026

Copy link
Copy Markdown
image

It should be running

irfanuddinahmad and others added 2 commits October 22, 2026 15:17
Keep requirements/*.txt deleted; they are replaced by uv.lock.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Main hasn't uploaded coverage since 2023, and the step used the
deprecated codecov uploader.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@irfanuddinahmad

Copy link
Copy Markdown
Contributor Author

That's the required check tests (3.12, pinned) from main's old matrix. The jobs now report as tests (3.12, django42), tests (3.12, django52) and tests (3.12, translations), so the old name never shows up. A repo admin needs to update the required check (or admin-merge).

irfanuddinahmad and others added 2 commits October 23, 2026 08:22
Keep requirements/*.txt deleted; they are replaced by uv.lock.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts:
#	.github/workflows/ci.yml
#	.github/workflows/upgrade-python-requirements.yml
Comment thread pyproject.toml
# and will be overwritten the next time `make upgrade` is run.
# - GLOBAL constraints: edit edx_lint/files/common_constraints.txt
# - REPO-SPECIFIC constraints: edit [tool.edx_lint].uv_constraints in this file
constraint-dependencies = [

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.

These are stale against the current edx-lint constraints, rerunning edx_lint write_uv_constraints adds social-auth-app-django<6.0.0, social-auth-core<5.0.0 and pip<26.2.1. Without them the lock resolves social-auth-app-django 6.0.0 and social-auth-core 5.0.2 alongside edx-drf-extensions 10.6.0 (openedx/edx-drf-extensions#561), and sign-in breaks. Driving the login flow with the Django test client in the django52 env:

GET /login/            -> 302 /login/edx-oauth2/
GET /login/edx-oauth2/ -> 405 Method Not Allowed (GET)

With main's pins the second request redirects to the provider's /oauth2/authorize. CI doesn't catch this because no test drives the login view. Rerun the constraint writer and then relock.

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.

Reran edx_lint write_uv_constraints in 793cc76, so the lock now has social-auth-app-django 5.4.3 and social-auth-core 4.9.1, the same as main.

Comment thread pyproject.toml Outdated
]
# Legacy Django 4.2 support - kept independent from `test` via [tool.uv].conflicts
# below so `uv.lock` carries two separate, correct resolutions.
django42 = [

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.

The new lock pulls in about ten months of upgrades that the weekly bot PRs have been offering and that haven't been merged: 58 of the 117 production packages change version compared to requirements/production.txt on main, about 16 of them major bumps (edx-auth-backends 5, edx-rest-api-client 7, edx-opaque-keys 4, edx-rbac 3, openedx-events 11, redis 8, gunicorn 26, ...). We should seed uv.lock from main's pins so this PR doesn't change what runs, and let the first make upgrade PR take the upgrades on their own.

Main's pins don't install on Django 4.2 (django-filter 25.2 needs 5.2+), and main's CI never ran 4.2, so I think this group and its conflicts entries should go. With it removed, adding main's production pins to constraint-dependencies, running uv lock, then restoring the constraints and running uv lock again gave a production export that matches main apart from setuptools and the win32-only colorama, and the django52 tests pass on it.

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.

Done in 793cc76: seeded uv.lock from main's pins and removed the django42 group and its conflicts. The production export now matches requirements/production.txt except setuptools and colorama.

Comment thread .github/workflows/ci.yml Outdated
run: make style isort_check pii_check check_keywords

- name: Install Dependencies
run: uv sync --group ci

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
run: uv sync --group ci
run: uv sync --locked --group ci

We want --locked on the uv sync calls in CI so a stale uv.lock fails the build instead of being re-resolved on the runner. Same for the quality job's uv sync below.

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.

Done in ec27846. Also added it to the same calls in the other PRs in this batch.

Resolve uv.lock from the versions pinned in requirements/*.txt on main so this
migration doesn't change what gets installed. Upgrades come in with the first
make upgrade after this merges.

Drop the django42 group, its conflicts and its tox/CI entry: main's pins need
Django 5.2 (django-filter 25.2) and main's CI never ran 4.2.

Rerun edx_lint write_uv_constraints, which adds the social-auth caps that keep
edx-drf-extensions' login flow working.

Remove the duplicated _rand_numeric_string/_rand_created_at helpers in
test_stripe_event_handlers.py, which pylint 4.0.4 (main's pin) flags as E0102.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- Add --locked to the CI uv sync/uv run calls.
- Replace the virtualenv setup in docs/getting_started.rst and docs/testing.rst with the uv .venv flow.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@feanil
feanil merged commit cd6dc35 into main Nov 3, 2026
9 of 10 checks passed
@feanil
feanil deleted the irfanuddinahmad/uv-migration branch November 3, 2026 15:53
@github-project-automation github-project-automation Bot moved this from In Eng Review to Done in Contributions Nov 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core contributor PR author is a Core Contributor (who may or may not have write access to this repo). open-source-contribution PR author is not from Axim or 2U

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

4 participants