Skip to content

Commit da47910

Browse files
authored
Add correct type annotations for tuple return types (#149)
* style: fix some tuple type style lint issues Signed-off-by: Grant Timmerman <[email protected]> * ci: remove other files Signed-off-by: Grant Timmerman <[email protected]>
1 parent 705e8b4 commit da47910

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

cloudevents/http/http_methods.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def _to_http(
9494
event: CloudEvent,
9595
format: str = converters.TypeStructured,
9696
data_marshaller: types.MarshallerType = None,
97-
) -> (dict, typing.Union[bytes, str]):
97+
) -> typing.Tuple[dict, typing.Union[bytes, str]]:
9898
"""
9999
Returns a tuple of HTTP headers/body dicts representing this cloudevent
100100
@@ -125,7 +125,7 @@ def _to_http(
125125

126126
def to_structured(
127127
event: CloudEvent, data_marshaller: types.MarshallerType = None
128-
) -> (dict, typing.Union[bytes, str]):
128+
) -> typing.Tuple[dict, typing.Union[bytes, str]]:
129129
"""
130130
Returns a tuple of HTTP headers/body dicts representing this cloudevent. If
131131
event.data is a byte object, body will have a data_base64 field instead of
@@ -143,7 +143,7 @@ def to_structured(
143143

144144
def to_binary(
145145
event: CloudEvent, data_marshaller: types.MarshallerType = None
146-
) -> (dict, typing.Union[bytes, str]):
146+
) -> typing.Tuple[dict, typing.Union[bytes, str]]:
147147
"""
148148
Returns a tuple of HTTP headers/body dicts representing this cloudevent
149149
@@ -164,12 +164,12 @@ def to_binary(
164164
@deprecated(deprecated_in="1.0.2", details="Use to_binary function instead")
165165
def to_binary_http(
166166
event: CloudEvent, data_marshaller: types.MarshallerType = None
167-
) -> (dict, typing.Union[bytes, str]):
167+
) -> typing.Tuple[dict, typing.Union[bytes, str]]:
168168
return to_binary(event, data_marshaller)
169169

170170

171171
@deprecated(deprecated_in="1.0.2", details="Use to_structured function instead")
172172
def to_structured_http(
173173
event: CloudEvent, data_marshaller: types.MarshallerType = None
174-
) -> (dict, typing.Union[bytes, str]):
174+
) -> typing.Tuple[dict, typing.Union[bytes, str]]:
175175
return to_structured(event, data_marshaller)

cloudevents/sdk/converters/binary.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def read(
5151

5252
def write(
5353
self, event: event_base.BaseEvent, data_marshaller: types.MarshallerType
54-
) -> (dict, bytes):
54+
) -> typing.Tuple[dict, bytes]:
5555
return event.MarshalBinary(data_marshaller)
5656

5757

cloudevents/sdk/converters/structured.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def read(
5151

5252
def write(
5353
self, event: event_base.BaseEvent, data_marshaller: types.MarshallerType
54-
) -> (dict, bytes):
54+
) -> typing.Tuple[dict, bytes]:
5555
http_headers = {"content-type": self.MIME_TYPE}
5656
return http_headers, event.MarshalJSON(data_marshaller).encode("utf-8")
5757

cloudevents/sdk/event/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ def Properties(self, with_nullable=False) -> dict:
174174

175175
return props
176176

177-
def Get(self, key: str) -> (object, bool):
177+
def Get(self, key: str) -> typing.Tuple[object, bool]:
178178
formatted_key = "ce__{0}".format(key.lower())
179179
ok = hasattr(self, formatted_key)
180180
value = getattr(self, formatted_key, None)
@@ -284,7 +284,7 @@ def UnmarshalBinary(
284284

285285
def MarshalBinary(
286286
self, data_marshaller: types.MarshallerType
287-
) -> (dict, bytes):
287+
) -> typing.Tuple[dict, bytes]:
288288
if data_marshaller is None:
289289
data_marshaller = json.dumps
290290
headers = {}

0 commit comments

Comments
 (0)