Skip to content

feat: migrate callers off FEATURES-as-dict access#38772

Draft
feanil wants to merge 24 commits into
feanil/features-dict-bridgefrom
feanil/features-dict-migration
Draft

feat: migrate callers off FEATURES-as-dict access#38772
feanil wants to merge 24 commits into
feanil/features-dict-bridgefrom
feanil/features-dict-migration

Conversation

@feanil

@feanil feanil commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Second PR in the FEATURES-as-dict migration stack. Stacked on #38818 (the bridge).

Per-flag refactor: commits that move callers off settings.FEATURES['X'] / patch.dict(settings.FEATURES, …) and onto settings.X / @override_settings(X=…). The underlying flat settings already exist in lms/envs/common.py, cms/envs/common.py, and the shared openedx/envs/common.py — the env files were previously flattened, so this PR only touches call sites (plus a few flag definitions that needed to move into the shared file).

Stack:

@feanil feanil force-pushed the feanil/fix-deprecation-warnings branch from 1b8c4e8 to 7f5dbc2 Compare June 16, 2026 18:52
@feanil feanil force-pushed the feanil/features-dict-migration branch 3 times, most recently from 9ffdb02 to f9359f9 Compare June 17, 2026 14:27
Base automatically changed from feanil/fix-deprecation-warnings to master June 17, 2026 15:33
@feanil feanil force-pushed the feanil/features-dict-migration branch 4 times, most recently from 60dd592 to 4ecd09f Compare June 23, 2026 18:42
@feanil feanil force-pushed the feanil/features-dict-migration branch 4 times, most recently from 858d762 to 346382f Compare June 26, 2026 19:30
@feanil feanil changed the base branch from master to feanil/features-dict-bridge June 26, 2026 19:31
feanil and others added 14 commits June 26, 2026 15:59
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Production reads use getattr(settings, ...); tests use
@override_settings(ENABLE_CREATOR_GROUP=...). Mixed-flag patches keep the
other flag in patch.dict until its own migration.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- Production reads use getattr(settings, ...); tests use
  @override_settings(CERTIFICATES_HTML_VIEW=...).
- Drop now-unused FEATURES_WITH_CERTS_ENABLED/_DISABLED helpers.
- FEATURES_WITH_CUSTOM_CERTS_ENABLED keeps CUSTOM_CERTIFICATE_TEMPLATES_ENABLED
  until that flag migrates.
- Mixed-flag patches keep the other flag in patch.dict.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- test_200_for_lti_provider's post-`with` modulestore assertions relied
  on a state leak (the old code aliased settings.FEATURES without
  .copy(), so the mutation persisted). They now run inside the
  with-block.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- Tests that previously had @patch.dict on setUp/setUpClass move the
  override to the class level. @override_settings as a setUp decorator
  conflicts with CacheIsolationMixin's own override_settings push/pop —
  the wrong layer gets popped on setUp exit, leaving settings.CACHES
  broken for subsequent test methods.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Running `pytest openedx/core/djangoapps/embargo/tests/` in isolation
fails one test because `test_redirect_if_blocked_courseware` mocks
`embargo.api.check_course_access`, and the mocked call triggers the
first-time import of `embargo.views`. views.py's `from .api import
check_course_access` captures the MagicMock as
`views.check_course_access` permanently. CI doesn't hit this because
earlier shard directories preload `embargo.views` before any mock
fires. Reproduces on master.

Calling via the module attribute resolves at call time, so future
mocks on the api function stay visible to the view.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
feanil and others added 10 commits June 26, 2026 15:59
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…-dict

Default flips from raising KeyError (`settings.FEATURES['…']` direct
subscript, only safe inside an active patch) to False (`getattr` with
default) — the flag isn't defined in any env file.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@feanil feanil force-pushed the feanil/features-dict-migration branch from 346382f to 520006a Compare June 26, 2026 19:59
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.

1 participant