Skip to content

feat: Add ability to check events that are type annotated#535

Open
bmtcril wants to merge 1 commit into
masterfrom
bmtcril/update_events_annotation
Open

feat: Add ability to check events that are type annotated#535
bmtcril wants to merge 1 commit into
masterfrom
bmtcril/update_events_annotation

Conversation

@bmtcril

@bmtcril bmtcril commented Apr 16, 2026

Copy link
Copy Markdown
Contributor

Description:

Currently adding a type annotation to an openedx-events definition causes the linter to crash astroid:

  File "/home/ty/Dev/edx-lint/edx_lint/pylint/events_annotation/events_annotation_check.py", line 154, in visit_call
    if self._is_annotation_missing_or_incorrect(node):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ty/Dev/edx-lint/edx_lint/pylint/events_annotation/events_annotation_check.py", line 211, in _is_annotation_missing_or_incorrect
    node_event_name = node.parent.targets[0].name
                      ^^^^^^^^^^^^^^^^^^^
AttributeError: 'AnnAssign' object has no attribute 'targets'. Did you mean: 'target'?

This fix handles the use case of:

TRACKING_EVENT_EMITTED: OpenEdxPublicSignal = OpenEdxPublicSignal(
    event_type="org.openedx.analytics.tracking.event.emitted.v1",
    data={
        "tracking_log": TrackingLogData,
    },
)

as well as some linting issues in that file.

Merge checklist:

  • All reviewers approved
  • CI build is green
  • If adding new checks, followed how_tos/0001-adding-new-checks.rst
  • Changelog record added (if needed)
  • Documentation updated (not only docstrings) (if needed)
  • Commits are squashed

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