Repository navigation
Conversation
Explain the attributes-vs-data split, list the required and optional CloudEvents v1.0 attributes with a spec reference, and add a usage example. Document why the mapping interface (__getitem__/get) exposes context attributes only and why the payload must be read via .data. Fixes cloudevents#247 Signed-off-by: Jean Pierre Mandujano G. <jeanpierre.mandujano@gmail.com>
manduinca
force-pushed
the
docs/247-abstract-cloudevent-docstring
branch
from
September 20, 2026 08:47
7029159 to
1487fae
Compare
There was a problem hiding this comment.
🟡 Changes recommended
The documentation incorrectly claims that direct instantiation is prohibited and that data lookups always raise KeyError or return a default, overlooking a separate data attribute.
2 open issues
What changed in this PR
This documentation-only PR addresses #247 by clarifying the distinction between CloudEvent context attributes and payload data in the shared abstract contract.
Changes:
- Lists required and optional attributes and links to the CloudEvents specification.
- Describes the class’s intended abstract role and adds a usage example.
- Explains payload access through
.dataorget_data, separately from mapping access.
| File | Description |
|---|---|
src/cloudevents/v1/abstract/event.py |
Expands class, __getitem__, and get docstrings without changing runtime behavior. |
Review effort: Balanced
Comment on lines
+44
to
+45
| Pydantic variants). It is abstract and cannot be instantiated directly; | ||
| use a concrete subclass or its `create` factory instead. |
Comment on lines
+49
to
+52
| interface exposes the attributes only: the event `data` is never part of | ||
| it and must be read through the `.data` accessor (or `get_data`). This is | ||
| why `event["data"]` raises a `KeyError` and `event.get("data")` returns the | ||
| default instead of the payload. |
I clarified which base methods are unimplemented and how HTTP attribute lookups interact with the event payload. Signed-off-by: Jean Pierre Mandujano G. <jeanpierre.mandujano@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Fixes #247
Reworks the
abstract.CloudEventdocstring to explain the attributes vs data split that a couple of people found confusing in the issue. It now lists the required (id,source,type,specversion) and optional attributes, links to the CloudEvents spec, notes the class is abstract, and adds a runnable example.It also documents on
__getitem__andgetwhy the payload is not reachable through the mapping interface, soevent["data"]raisesKeyErrorandevent.get("data")returns the default instead of the payload.The file moved from
cloudevents/abstract/event.pytosrc/cloudevents/v1/abstract/event.pysince the issue was filed, so this updates it there. Docstrings only, no behavior change.