From 01041e7cd5079a9a72bcc5479f942125f60496d7 Mon Sep 17 00:00:00 2001 From: Alexander Tkachev Date: Sat, 23 Jul 2022 00:23:39 +0300 Subject: [PATCH] docs: abstract cloudevent Signed-off-by: Alexander Tkachev --- cloudevents/abstract/event.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/cloudevents/abstract/event.py b/cloudevents/abstract/event.py index d480f5f..e3c79da 100644 --- a/cloudevents/abstract/event.py +++ b/cloudevents/abstract/event.py @@ -4,16 +4,32 @@ from typing import TypeVar class CloudEvent(abc.ABC): + """ + Used internally for multi-framework event type integration + """ + @classmethod def create( cls, attributes: typing.Dict[str, typing.Any], data: typing.Optional[typing.Any], ) -> "CloudEvent": + """ + Factory function. + We SHOULD NOT use the __init__ function as the factory because + we MUST NOT assume how the __init__ function looks across different python + frameworks + """ raise NotImplementedError() @property def _attributes_read_model(self) -> typing.Dict[str, typing.Any]: + """ + :return: dict read model of all of the attributes of this event + + you MUST NOT mutate this dict + implementation MAY assume the dic will not be mutated + """ raise NotImplementedError() @property