Skip to content

refactor: remove dead FEATURES-derived assignments (xmodule + production) - #39016

Draft
feanil wants to merge 2 commits into
masterfrom
feanil/features-dict-remove-dead-getattr
Draft

refactor: remove dead FEATURES-derived assignments (xmodule + production)#39016
feanil wants to merge 2 commits into
masterfrom
feanil/features-dict-remove-dead-getattr

Conversation

@feanil

@feanil feanil commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Removes module-level assignments derived from the FEATURES dict that nothing reads.

  • xmodule/capa_block.py — the try/except ImproperlyConfigured FEATURES = getattr(settings, "FEATURES", {}) grab, orphaned when the flags it once gated were deprecated (the extracted xblocks_contrib copy already omits it). Also drops the now-unused ImproperlyConfigured import (settings stays).
  • xmodule/partitions/partitions_service.py — a long-unused module-level FEATURES grab; drops it and the now-unused settings import.
  • lms/envs/production.py & cms/envs/production.pyENV_FEATURES = _YAML_TOKENS.get("FEATURES", {}), a legacy compat export alongside ENV_TOKENS/AUTH_TOKENS that nothing reads. ENV_TOKENS/AUTH_TOKENS (the actually-used exports) are unchanged, so ENV_TOKENS["FEATURES"] still works.

Safety

  • None of capa_block.FEATURES, partitions_service.FEATURES, or ENV_FEATURES is imported anywhere in the openedx GitHub org (org-wide code search: 0 hits each). For contrast, ENV_TOKENS returns many hits across the org — so the search works, and these three are genuinely unused.
  • AST analysis of the app tree shows no reader.
  • xmodule/partitions/tests/test_partitions.py + xmodule/tests/test_capa_block.py pass (218); modules import cleanly; ruff clean.

feanil and others added 2 commits August 24, 2026 09:51
xmodule/capa_block.py and xmodule/partitions/partitions_service.py each grabbed the
FEATURES dict at import time into a module-level variable that nothing reads:

    FEATURES = getattr(settings, "FEATURES", {})

In capa_block this was orphaned when the flags it once gated were deprecated (the extracted
xblocks_contrib copy already omits it); in partitions_service it has been unused for a long
time. Neither module-level name is imported anywhere in the openedx GitHub org (confirmed by
org-wide code search) and AST analysis shows no reader.

Remove both assignments and the imports they leave unused: ImproperlyConfigured in
capa_block (settings is still used elsewhere and stays) and django.conf.settings in
partitions_service.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
lms/envs/production.py and cms/envs/production.py defined
ENV_FEATURES = _YAML_TOKENS.get("FEATURES", {}) alongside the legacy ENV_TOKENS / AUTH_TOKENS
compat exports, but nothing reads ENV_FEATURES -- not in this repo, and not anywhere in the
openedx GitHub org (org-wide code search: 0 importers, in contrast to ENV_TOKENS, which many
plugins/IDAs still import). Remove it. ENV_TOKENS and AUTH_TOKENS (the actually-used exports)
are unchanged, so ENV_TOKENS["FEATURES"] still works for any external consumer.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@feanil feanil changed the title refactor: remove dead settings.FEATURES grabs in xmodule refactor: remove dead FEATURES-derived assignments (xmodule + production) Aug 25, 2026
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