Skip to content

feat: move commonly used attributes from XModuleMixin to XBlock#906

Open
irtazaakram wants to merge 2 commits intomasterfrom
add-required-attrs
Open

feat: move commonly used attributes from XModuleMixin to XBlock#906
irtazaakram wants to merge 2 commits intomasterfrom
add-required-attrs

Conversation

@irtazaakram
Copy link
Copy Markdown
Member

This pull request is related to openedx/openedx-platform#38271

It moves a set of commonly used attributes out of the legacy XModuleMixin into XBlock, since they are not specific to XModule behavior and are widely relied upon across most XBlocks.

The update also includes corresponding tests (generated with assistance from Claude Code), which have been carefully reviewed and refined.

@irtazaakram irtazaakram self-assigned this Apr 15, 2026
@kdmccormick kdmccormick self-requested a review April 17, 2026 13:49
Copy link
Copy Markdown
Member

@kdmccormick kdmccormick left a comment

Choose a reason for hiding this comment

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

Just one request, good to merge otherwise.

Comment thread xblock/core.py
Comment on lines +981 to +985

This method avoids direct attribute access and uses ``getattr`` to safely
handle cases where attributes like ``display_name`` or ``usage_key`` may
not be present.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

usage_key is always present. Anyway, this is an implementation detail, so it is better to leave it out of the docstring.

Suggested change
This method avoids direct attribute access and uses ``getattr`` to safely
handle cases where attributes like ``display_name`` or ``usage_key`` may
not be present.

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.

2 participants