Skip to content

docs: clarify abstract.CloudEvent docstring (attributes vs data)#302

Open
manduinca wants to merge 1 commit into
cloudevents:mainfrom
manduinca:docs/247-abstract-cloudevent-docstring
Open

docs: clarify abstract.CloudEvent docstring (attributes vs data)#302
manduinca wants to merge 1 commit into
cloudevents:mainfrom
manduinca:docs/247-abstract-cloudevent-docstring

Conversation

@manduinca

Copy link
Copy Markdown

Fixes #247

Reworks the abstract.CloudEvent docstring 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__ and get why the payload is not reachable through the mapping interface, so event["data"] raises KeyError and event.get("data") returns the default instead of the payload.

The file moved from cloudevents/abstract/event.py to src/cloudevents/v1/abstract/event.py since the issue was filed, so this updates it there. Docstrings only, no behavior change.

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>
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.

Improve the docstring of abstract.CloudEvent

1 participant