refactor: remove optional type

Signed-off-by: Alexander Tkachev <sasha64sasha@gmail.com>
This commit is contained in:
Alexander Tkachev 2022-07-25 01:53:52 +03:00
parent fbc063244b
commit 0c2bafc423
3 changed files with 5 additions and 5 deletions

View File

@ -16,7 +16,7 @@ import typing
from cloudevents import exceptions as cloud_exceptions from cloudevents import exceptions as cloud_exceptions
from cloudevents.abstract import AnyCloudEvent from cloudevents.abstract import AnyCloudEvent
from cloudevents.http import CloudEvent, is_binary from cloudevents.http import is_binary
from cloudevents.http.mappings import _marshaller_by_format, _obj_by_version from cloudevents.http.mappings import _marshaller_by_format, _obj_by_version
from cloudevents.http.util import _json_or_string from cloudevents.http.util import _json_or_string
from cloudevents.sdk import converters, marshaller, types from cloudevents.sdk import converters, marshaller, types
@ -37,9 +37,9 @@ def to_json(
def from_json( def from_json(
event_type: typing.Type[AnyCloudEvent],
data: typing.Union[str, bytes], data: typing.Union[str, bytes],
data_unmarshaller: types.UnmarshallerType = None, data_unmarshaller: types.UnmarshallerType = None,
event_type: typing.Type[AnyCloudEvent] = CloudEvent,
) -> AnyCloudEvent: ) -> AnyCloudEvent:
""" """
Cast json encoded data into an CloudEvent Cast json encoded data into an CloudEvent
@ -58,10 +58,10 @@ def from_json(
def from_http( def from_http(
event_type: typing.Type[AnyCloudEvent],
headers: typing.Dict[str, str], headers: typing.Dict[str, str],
data: typing.Union[str, bytes, None], data: typing.Union[str, bytes, None],
data_unmarshaller: types.UnmarshallerType = None, data_unmarshaller: types.UnmarshallerType = None,
event_type: typing.Type[AnyCloudEvent] = CloudEvent,
) -> AnyCloudEvent: ) -> AnyCloudEvent:
""" """
Unwrap a CloudEvent (binary or structured) from an HTTP request. Unwrap a CloudEvent (binary or structured) from an HTTP request.

View File

@ -38,7 +38,7 @@ def from_http(
e.g. lambda x: x or lambda x: json.loads(x) e.g. lambda x: x or lambda x: json.loads(x)
:type data_unmarshaller: types.UnmarshallerType :type data_unmarshaller: types.UnmarshallerType
""" """
return _abstract_from_http(headers, data, data_unmarshaller, event_type=CloudEvent) return _abstract_from_http(CloudEvent, headers, data, data_unmarshaller)
# backwards compatibility # backwards compatibility

View File

@ -32,7 +32,7 @@ def from_json(
:type data_unmarshaller: typing.Callable :type data_unmarshaller: typing.Callable
:returns: CloudEvent representing given cloudevent json object :returns: CloudEvent representing given cloudevent json object
""" """
return _abstract_from_json(data, data_unmarshaller, event_type=CloudEvent) return _abstract_from_json(CloudEvent, data, data_unmarshaller)
# backwards compatibility # backwards compatibility