docs: clarify abstract.CloudEvent docstring (attributes vs data)#302
Open
manduinca wants to merge 1 commit into
Open
docs: clarify abstract.CloudEvent docstring (attributes vs data)#302manduinca wants to merge 1 commit into
manduinca wants to merge 1 commit into
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>
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.