Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Lint against imports of openedx_catalog internals in openedx-core

Chiusa
#860 1 commento 0 reazioni 1 assegnatario Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@ufedaseyeuconsultant ci sta già lavorando.

Dal 9/10/2026.

  • #861 di @ufedaseyeuconsultant — aperta

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

Description

Add an import-linter contract to openedx-core that only lets other apps import openedx_catalog's public modules (api, models_api, data, tests), matching the rule openedx-platform already enforces. That way an import of openedx_catalog's internals fails CI in openedx-core instead of surfacing later, when openedx-platform installs a new openedx-core release.

Context

  • openedx/openedx-core#853 fixed an import of openedx_catalog.models in CBE code. openedx-platform's import linter caught it during openedx/openedx-platform#39199, the PR bumping openedx-core's version there; openedx-core's own linter had no rule against it.
  • @ormsbee asked for this contract in his review of #853 and agreed it should be a separate follow-up PR so the version bump wasn't held up.
  • Only openedx_catalog is in scope. Other apps, such as openedx_tagging, have no models_api.py yet, so adding them would need a separate design decision.

Acceptance Criteria

  • .importlinter has a contract that treats openedx_catalog as an isolated app: code outside openedx_catalog may import only its api, models_api, data, and tests modules.
  • lint-imports passes on main with the new contract. Today the only import of openedx_catalog from another app is from openedx_catalog.models_api import CourseRun in criteria.py, which is allowed.
  • The PR description shows that the contract catches a real violation: temporarily changing that criteria.py line back to from openedx_catalog.models import CourseRun makes lint-imports fail and name that line.
  • openedx_tagging and the other apps are not added to the contract.
Technical Details

This is a suggested approach, not the source of truth. The User Story, Description, and Acceptance Criteria define what must be true when the work is done.

Approach

  1. Copy openedx-platform's IsolatedAppsContract (openedx/testing/importlinter/isolated_apps_contract.py, about 60 lines) into openedx-core. It has to be a copy because openedx-core must never import from openedx-platform. Put it in the root-level test_utils package (for example test_utils/importlinter.py) rather than under src/, so the published package doesn't ship lint tooling.
  2. Register it in .importlinter with contract_types = isolated_apps: test_utils.importlinter.IsolatedAppsContract in the [importlinter] section, then add a contract with isolated_apps = openedx_catalog and allowed_modules = api, models_api, data, tests, matching openedx-platform's contract so the two repos enforce the same rule.
  3. Add a short comment above the new contract explaining why it exists: openedx-platform enforces the same rule, so a violation here would otherwise only surface when openedx-platform installs a new openedx-core release.

lint-imports already runs in CI through tox -e quality, so no workflow change is needed.

Additional context

  • openedx-platform's contract definition: the isolated_apps block in openedx-platform's pyproject.toml.
Lingua principale
Python
Stelle
10
Fork
33
Merge medio
2g 23h
PR unite (30g)
22

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di openedx/openedx-core

Tutte le issue di openedx/openedx-core

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.