Skip to content

Commit 8773319

Browse files
authored
Fix formatting (#131)
* Fix formatting for latest black Signed-off-by: Dustin Ingram <[email protected]> * Add flake8 for linting Signed-off-by: Dustin Ingram <[email protected]> * Fix flake8 lint errors Signed-off-by: Dustin Ingram <[email protected]>
1 parent 390f594 commit 8773319

19 files changed

+39
-60
lines changed

cloudevents/http/__init__.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,14 @@
1111
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
1212
# License for the specific language governing permissions and limitations
1313
# under the License.
14-
import json
15-
import typing
1614

17-
from cloudevents.http.event import CloudEvent
18-
from cloudevents.http.event_type import is_binary, is_structured
19-
from cloudevents.http.http_methods import (
15+
from cloudevents.http.event import CloudEvent # noqa
16+
from cloudevents.http.event_type import is_binary, is_structured # noqa
17+
from cloudevents.http.http_methods import ( # noqa
2018
from_http,
2119
to_binary,
2220
to_binary_http,
2321
to_structured,
2422
to_structured_http,
2523
)
26-
from cloudevents.http.json_methods import from_json, to_json
24+
from cloudevents.http.json_methods import from_json, to_json # noqa

cloudevents/http/event_type.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ def is_binary(headers: typing.Dict[str, str]) -> bool:
77
"""Uses internal marshallers to determine whether this event is binary
88
:param headers: the HTTP headers
99
:type headers: typing.Dict[str, str]
10-
:returns bool: returns a bool indicating whether the headers indicate a binary event type
10+
:returns bool: returns a bool indicating whether the headers indicate
11+
a binary event type
1112
"""
1213
headers = {key.lower(): value for key, value in headers.items()}
1314
content_type = headers.get("content-type", "")
@@ -19,7 +20,8 @@ def is_structured(headers: typing.Dict[str, str]) -> bool:
1920
"""Uses internal marshallers to determine whether this event is structured
2021
:param headers: the HTTP headers
2122
:type headers: typing.Dict[str, str]
22-
:returns bool: returns a bool indicating whether the headers indicate a structured event type
23+
:returns bool: returns a bool indicating whether the headers indicate
24+
a structured event type
2325
"""
2426
headers = {key.lower(): value for key, value in headers.items()}
2527
content_type = headers.get("content-type", "")

cloudevents/http/http_methods.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import cloudevents.exceptions as cloud_exceptions
77
from cloudevents.http.event import CloudEvent
8-
from cloudevents.http.event_type import is_binary, is_structured
8+
from cloudevents.http.event_type import is_binary
99
from cloudevents.http.mappings import _marshaller_by_format, _obj_by_version
1010
from cloudevents.http.util import _json_or_string
1111
from cloudevents.sdk import converters, marshaller, types
@@ -124,7 +124,7 @@ def _to_http(
124124

125125

126126
def to_structured(
127-
event: CloudEvent, data_marshaller: types.MarshallerType = None,
127+
event: CloudEvent, data_marshaller: types.MarshallerType = None
128128
) -> (dict, typing.Union[bytes, str]):
129129
"""
130130
Returns a tuple of HTTP headers/body dicts representing this cloudevent. If
@@ -142,7 +142,7 @@ def to_structured(
142142

143143

144144
def to_binary(
145-
event: CloudEvent, data_marshaller: types.MarshallerType = None,
145+
event: CloudEvent, data_marshaller: types.MarshallerType = None
146146
) -> (dict, typing.Union[bytes, str]):
147147
"""
148148
Returns a tuple of HTTP headers/body dicts representing this cloudevent
@@ -163,13 +163,13 @@ def to_binary(
163163

164164
@deprecated(deprecated_in="1.0.2", details="Use to_binary function instead")
165165
def to_binary_http(
166-
event: CloudEvent, data_marshaller: types.MarshallerType = None,
166+
event: CloudEvent, data_marshaller: types.MarshallerType = None
167167
) -> (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(
173-
event: CloudEvent, data_marshaller: types.MarshallerType = None,
173+
event: CloudEvent, data_marshaller: types.MarshallerType = None
174174
) -> (dict, typing.Union[bytes, str]):
175175
return to_structured(event, data_marshaller)

cloudevents/http/util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ def _json_or_string(content: typing.Union[str, bytes]):
1616
return None
1717
try:
1818
return json.loads(content)
19-
except (json.JSONDecodeError, TypeError) as e:
19+
except (json.JSONDecodeError, TypeError):
2020
return content

cloudevents/sdk/converters/structured.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class JSONHTTPCloudEventConverter(base.Converter):
2727
MIME_TYPE = "application/cloudevents+json"
2828

2929
def can_read(
30-
self, content_type: str, headers: typing.Dict[str, str] = {},
30+
self, content_type: str, headers: typing.Dict[str, str] = {}
3131
) -> bool:
3232
return (
3333
isinstance(content_type, str)

cloudevents/tests/test_base_events.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ def test_get_nonexistent_optional(event_class):
3030
event = event_class()
3131
event.SetExtensions({"ext1": "val"})
3232
res = event.Get("ext1")
33-
assert res[0] == "val" and res[1] == True
33+
assert res[0] == "val" and res[1] is True

cloudevents/tests/test_converters.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import pytest
1515

1616
from cloudevents.sdk import exceptions
17-
from cloudevents.sdk.converters import base, binary, structured
17+
from cloudevents.sdk.converters import base, binary
1818

1919

2020
def test_binary_converter_raise_unsupported():

cloudevents/tests/test_data_encaps_refs.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,12 @@
1212
# License for the specific language governing permissions and limitations
1313
# under the License.
1414

15-
import copy
16-
import io
1715
import json
1816
from uuid import uuid4
1917

2018
import pytest
2119

2220
from cloudevents.sdk import converters, marshaller
23-
from cloudevents.sdk.converters import structured
2421
from cloudevents.sdk.event import v1, v03
2522
from cloudevents.tests import data
2623

@@ -71,7 +68,6 @@ def test_general_binary_properties(event_class):
7168

7269
@pytest.mark.parametrize("event_class", [v03.Event, v1.Event])
7370
def test_general_structured_properties(event_class):
74-
copy_of_ce = copy.deepcopy(data.json_ce[event_class])
7571
m = marshaller.NewDefaultHTTPMarshaller()
7672
http_headers = {"content-type": "application/cloudevents+json"}
7773
event = m.FromRequest(

cloudevents/tests/test_event_from_request_converter.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,11 @@
1212
# License for the specific language governing permissions and limitations
1313
# under the License.
1414

15-
import io
1615
import json
1716

1817
import pytest
1918

20-
from cloudevents.sdk import exceptions, marshaller
19+
from cloudevents.sdk import marshaller
2120
from cloudevents.sdk.converters import binary, structured
2221
from cloudevents.sdk.event import v1, v03
2322
from cloudevents.tests import data

cloudevents/tests/test_event_pipeline.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
# License for the specific language governing permissions and limitations
1313
# under the License.
1414

15-
import io
1615
import json
1716

1817
import pytest

0 commit comments

Comments
 (0)