Currently, the data types for events are nicely integrated with VS Code and other tooling:
But this is not the case for events themselves. A lot of the key information is in comments like this:
|
# .. event_type: org.openedx.content_authoring.content.object.tags.changed.v1 |
|
# .. event_name: CONTENT_OBJECT_TAGS_CHANGED |
|
# .. event_description: Emitted when an object's tags are changed. |
|
# .. event_data: ContentObjectData |
|
# .. event_warning: **DEPRECATED** please use CONTENT_OBJECT_ASSOCIATIONS_CHANGED instead. |
|
CONTENT_OBJECT_TAGS_CHANGED = OpenEdxPublicSignal( |
|
event_type="org.openedx.content_authoring.content.object.tags.changed.v1", |
|
data={ |
|
"content_object": ContentObjectData, |
|
} |
|
) |
Which does not appear in relevant places in VS Code:
However, if we were to update our approach to put this data into "attribute docstrings" (as defined in PEP 257), then this information would show up in VS Code (as well as other tools like mkdocstrings):
😎
The code I used for the above screenshot looks like this:
CONTENT_OBJECT_TAGS_CHANGED = OpenEdxPublicSignal(
event_type="org.openedx.content_authoring.content.object.tags.changed.v1",
data={
"content_object": ContentObjectData,
}
)
"""
Emitted when an object's tags are changed.
**Warning**: This is DEPRECATED; please use `CONTENT_OBJECT_ASSOCIATIONS_CHANGED` instead.
Details |:
-|-
event_type | `org.openedx.content_authoring.content.object.tags.changed.v1`
event_name | `CONTENT_OBJECT_TAGS_CHANGED`
event_data | `content_object`: `ContentObjectData`
"""
Such attribute docstrings are not normally accessible at runtime (same as with the current comment approach), but you can use the griffe module to access them.
Currently, the data types for events are nicely integrated with VS Code and other tooling:
But this is not the case for events themselves. A lot of the key information is in comments like this:
openedx-events/openedx_events/content_authoring/signals.py
Lines 251 to 261 in 34d3fce
Which does not appear in relevant places in VS Code:
However, if we were to update our approach to put this data into "attribute docstrings" (as defined in PEP 257), then this information would show up in VS Code (as well as other tools like
mkdocstrings):😎
The code I used for the above screenshot looks like this:
Such attribute docstrings are not normally accessible at runtime (same as with the current comment approach), but you can use the griffe module to access them.