Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Aug 6, 2022
1 parent 76cef75 commit dab07d2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
24 changes: 12 additions & 12 deletions cloudevents/abstract/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ def create(
data: typing.Optional[typing.Any],
) -> "AnyCloudEvent":
"""
Creates a new instance of the CloudEvent using supplied `attributes`
Creates a new instance of the CloudEvent using supplied `attributes`
and `data`.
This method should be preferably used over the constructor to create events
while custom framework-specific implementations may require or assume
different arguments.
:param attributes: The attributes of the CloudEvent instance.
:param data: The payload of the CloudEvent instance.
:returns: A new instance of the CloudEvent created from the passed arguments.
Expand All @@ -36,12 +36,12 @@ def create(
def _get_attributes(self) -> typing.Dict[str, typing.Any]:
"""
Returns the attributes of the event.
The implementation MUST assume that the returned value MAY be mutated.
Having a function over a property simplifies integration for custom
Having a function over a property simplifies integration for custom
framework-specific implementations.
:returns: Attributes of the event.
"""
raise NotImplementedError()
Expand Down Expand Up @@ -70,10 +70,10 @@ def __eq__(self, other: typing.Any) -> bool:
def __getitem__(self, key: str) -> typing.Any:
"""
Returns a value of an attribute of the event denoted by the given `key`.
The `data` of the event should be accessed by the `.data` accessor rather
than this mapping.
:param key: The name of the event attribute to retrieve the value for.
:returns: The event attribute value.
"""
Expand All @@ -84,10 +84,10 @@ def get(
) -> typing.Optional[typing.Any]:
"""
Retrieves an event attribute value for the given `key`.
Returns the `default` value if the attribute for the given key does not exist.
The implementation MUST NOT throw an error when the key does not exist, but
The implementation MUST NOT throw an error when the key does not exist, but
rather should return `None` or the configured `default`.
:param key: The name of the event attribute to retrieve the value for.
Expand All @@ -111,7 +111,7 @@ def __len__(self) -> int:

def __contains__(self, key: str) -> bool:
"""
Determines if an attribute with a given `key` is present
Determines if an attribute with a given `key` is present
in the event attributes.
"""
return key in self._get_attributes()
Expand Down
12 changes: 6 additions & 6 deletions cloudevents/conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def to_json(
) -> typing.Union[str, bytes]:
"""
Converts given `event` to a JSON string.
:param event: A CloudEvent to be converted into a JSON string.
:param data_marshaller: Callable function which will cast `event.data`
into a JSON string.
Expand All @@ -44,11 +44,11 @@ def from_json(
) -> AnyCloudEvent:
"""
Parses JSON string `data` into a CloudEvent.
:param data: JSON string representation of a CloudEvent.
:param data_unmarshaller: Callable function that casts `data` to a
Python object.
:param event_type: A concrete type of the event into which the data is
:param event_type: A concrete type of the event into which the data is
deserialized.
:returns: A CloudEvent parsed from the given JSON representation.
"""
Expand Down Expand Up @@ -78,7 +78,7 @@ def from_http(
e.g. lambda x: x or lambda x: json.loads(x)
:param event_type: The actual type of CloudEvent to deserialize the event to.
:returns: A CloudEvent instance parsed from the passed HTTP parameters of
the specified type.
the specified type.
"""
if data is None or data == b"":
# Empty string will cause data to be marshalled into None
Expand Down Expand Up @@ -179,8 +179,8 @@ def to_structured(
data_marshaller: types.MarshallerType = None,
) -> typing.Tuple[dict, typing.Union[bytes, str]]:
"""
Returns a tuple of HTTP headers/body dicts representing this Cloud Event.
Returns a tuple of HTTP headers/body dicts representing this Cloud Event.
If event.data is a byte object, body will have a `data_base64` field instead of
`data`.
Expand Down

0 comments on commit dab07d2

Please sign in to comment.