Add correct type annotations for tuple return types (#149)

* style: fix some tuple type style lint issues

Signed-off-by: Grant Timmerman <timmerman+devrel@google.com>

* ci: remove other files

Signed-off-by: Grant Timmerman <timmerman+devrel@google.com>
This commit is contained in:
Grant Timmerman 2022-04-07 17:22:49 -07:00 committed by GitHub
parent 705e8b4100
commit da47910770
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 9 deletions

View File

@ -94,7 +94,7 @@ def _to_http(
event: CloudEvent,
format: str = converters.TypeStructured,
data_marshaller: types.MarshallerType = None,
) -> (dict, typing.Union[bytes, str]):
) -> typing.Tuple[dict, typing.Union[bytes, str]]:
"""
Returns a tuple of HTTP headers/body dicts representing this cloudevent
@ -125,7 +125,7 @@ def _to_http(
def to_structured(
event: CloudEvent, data_marshaller: types.MarshallerType = None
) -> (dict, typing.Union[bytes, str]):
) -> typing.Tuple[dict, typing.Union[bytes, str]]:
"""
Returns a tuple of HTTP headers/body dicts representing this cloudevent. If
event.data is a byte object, body will have a data_base64 field instead of
@ -143,7 +143,7 @@ def to_structured(
def to_binary(
event: CloudEvent, data_marshaller: types.MarshallerType = None
) -> (dict, typing.Union[bytes, str]):
) -> typing.Tuple[dict, typing.Union[bytes, str]]:
"""
Returns a tuple of HTTP headers/body dicts representing this cloudevent
@ -164,12 +164,12 @@ def to_binary(
@deprecated(deprecated_in="1.0.2", details="Use to_binary function instead")
def to_binary_http(
event: CloudEvent, data_marshaller: types.MarshallerType = None
) -> (dict, typing.Union[bytes, str]):
) -> typing.Tuple[dict, typing.Union[bytes, str]]:
return to_binary(event, data_marshaller)
@deprecated(deprecated_in="1.0.2", details="Use to_structured function instead")
def to_structured_http(
event: CloudEvent, data_marshaller: types.MarshallerType = None
) -> (dict, typing.Union[bytes, str]):
) -> typing.Tuple[dict, typing.Union[bytes, str]]:
return to_structured(event, data_marshaller)

View File

@ -51,7 +51,7 @@ class BinaryHTTPCloudEventConverter(base.Converter):
def write(
self, event: event_base.BaseEvent, data_marshaller: types.MarshallerType
) -> (dict, bytes):
) -> typing.Tuple[dict, bytes]:
return event.MarshalBinary(data_marshaller)

View File

@ -51,7 +51,7 @@ class JSONHTTPCloudEventConverter(base.Converter):
def write(
self, event: event_base.BaseEvent, data_marshaller: types.MarshallerType
) -> (dict, bytes):
) -> typing.Tuple[dict, bytes]:
http_headers = {"content-type": self.MIME_TYPE}
return http_headers, event.MarshalJSON(data_marshaller).encode("utf-8")

View File

@ -174,7 +174,7 @@ class BaseEvent(EventGetterSetter):
return props
def Get(self, key: str) -> (object, bool):
def Get(self, key: str) -> typing.Tuple[object, bool]:
formatted_key = "ce__{0}".format(key.lower())
ok = hasattr(self, formatted_key)
value = getattr(self, formatted_key, None)
@ -284,7 +284,7 @@ class BaseEvent(EventGetterSetter):
def MarshalBinary(
self, data_marshaller: types.MarshallerType
) -> (dict, bytes):
) -> typing.Tuple[dict, bytes]:
if data_marshaller is None:
data_marshaller = json.dumps
headers = {}