From 8a88ffee101afc77730d0331f2ae2a974dae6f37 Mon Sep 17 00:00:00 2001 From: Yurii Serhiichuk Date: Mon, 15 Aug 2022 01:47:38 +0300 Subject: [PATCH] chore: cleanup codebase and fix flake errors (#188) * deps: `flake8-strict` and `flake8-import-order` are not compatible with Black and modern Python anymore Signed-off-by: Yurii Serhiichuk * chore: Cleanup imports and remove obsolete `#noqa`. Signed-off-by: Yurii Serhiichuk * chore: sort imports. Signed-off-by: Yurii Serhiichuk * chore: Define `__all__` Signed-off-by: Yurii Serhiichuk * chore: Fix licenses and add __all__ to imports. Signed-off-by: Yurii Serhiichuk * chore: Fix formatting Signed-off-by: Yurii Serhiichuk * chore: Export `from_http` Signed-off-by: Yurii Serhiichuk * fix: Do not export functions of other modules from this one. Signed-off-by: Yurii Serhiichuk * chore: Resolve more flake8 errors Signed-off-by: Yurii Serhiichuk * chore: Fix more warnings Signed-off-by: Yurii Serhiichuk * docs: add a note in the changelog about the fixes. Signed-off-by: Yurii Serhiichuk * fix: imports in tests. Signed-off-by: Yurii Serhiichuk * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix: more import fixes. Signed-off-by: Yurii Serhiichuk * fix: use proper implementations as replacements. Signed-off-by: Yurii Serhiichuk * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci Signed-off-by: Yurii Serhiichuk Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- CHANGELOG.md | 3 ++ cloudevents/__init__.py | 24 --------------- cloudevents/abstract/__init__.py | 4 ++- cloudevents/abstract/event.py | 3 +- cloudevents/conversion.py | 16 ++-------- cloudevents/http/__init__.py | 30 ++++++++++++------- cloudevents/http/conversion.py | 15 +++++++++- cloudevents/http/http_methods.py | 8 ++--- cloudevents/http/json_methods.py | 4 +-- cloudevents/http/util.py | 2 +- cloudevents/pydantic/__init__.py | 14 +++------ cloudevents/pydantic/conversion.py | 1 - cloudevents/pydantic/event.py | 3 +- cloudevents/sdk/converters/__init__.py | 6 ++-- cloudevents/sdk/converters/util.py | 5 ++++ cloudevents/tests/data.py | 20 ++++++------- .../tests/test_backwards_compatability.py | 3 +- cloudevents/tests/test_data_encaps_refs.py | 4 +-- .../test_event_from_request_converter.py | 8 ++--- cloudevents/tests/test_event_pipeline.py | 26 ++++++++-------- .../tests/test_event_to_request_converter.py | 4 +-- cloudevents/tests/test_http_conversions.py | 3 +- cloudevents/tests/test_http_events.py | 4 +-- .../tests/test_pydantic_conversions.py | 3 +- cloudevents/tests/test_pydantic_events.py | 9 +++--- requirements/dev.txt | 2 -- requirements/test.txt | 2 -- 27 files changed, 106 insertions(+), 120 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d8d870fe..d0aee410 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 moved under `cloudevents.http.conversion`. - Deprecated `cloudevents.http.util` module. +### Fixed +- Multiple PEP issues, license headers, module-level exports. ([#188]) ## [1.5.0] — 2022-08-06 @@ -199,3 +201,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 [#182]: https://github.com/cloudevents/sdk-python/pull/182 [#184]: https://github.com/cloudevents/sdk-python/pull/184 [#186]: https://github.com/cloudevents/sdk-python/pull/186 +[#188]: https://github.com/cloudevents/sdk-python/pull/188 diff --git a/cloudevents/__init__.py b/cloudevents/__init__.py index eacb1de0..91d19737 100644 --- a/cloudevents/__init__.py +++ b/cloudevents/__init__.py @@ -11,29 +11,5 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. __version__ = "1.5.0" diff --git a/cloudevents/abstract/__init__.py b/cloudevents/abstract/__init__.py index c4c7336c..1e62df8d 100644 --- a/cloudevents/abstract/__init__.py +++ b/cloudevents/abstract/__init__.py @@ -12,4 +12,6 @@ # License for the specific language governing permissions and limitations # under the License. -from cloudevents.abstract.event import AnyCloudEvent, CloudEvent # noqa +from cloudevents.abstract.event import AnyCloudEvent, CloudEvent + +__all__ = [AnyCloudEvent, CloudEvent] diff --git a/cloudevents/abstract/event.py b/cloudevents/abstract/event.py index f6fe732d..13e50397 100644 --- a/cloudevents/abstract/event.py +++ b/cloudevents/abstract/event.py @@ -14,7 +14,6 @@ import typing from abc import abstractmethod -from typing import TypeVar class CloudEvent: @@ -134,4 +133,4 @@ def __repr__(self) -> str: return str({"attributes": self._get_attributes(), "data": self._get_data()}) -AnyCloudEvent = TypeVar("AnyCloudEvent", bound=CloudEvent) +AnyCloudEvent = typing.TypeVar("AnyCloudEvent", bound=CloudEvent) diff --git a/cloudevents/conversion.py b/cloudevents/conversion.py index 71154bf1..3f41769c 100644 --- a/cloudevents/conversion.py +++ b/cloudevents/conversion.py @@ -11,18 +11,6 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. import datetime import enum import json @@ -42,10 +30,10 @@ def _best_effort_serialize_to_json( Serializes the given value into a JSON-encoded string. Given a None value returns None as is. - Given a non-JSON-serializable value returns return the value as is. + Given a non-JSON-serializable value returns the value as is. :param value: The value to be serialized into a JSON string. - :return: JSON string of the given value OR None OR given value. + :returns: JSON string of the given value OR None OR given value. """ if value is None: return None diff --git a/cloudevents/http/__init__.py b/cloudevents/http/__init__.py index 64b41bbc..591f2694 100644 --- a/cloudevents/http/__init__.py +++ b/cloudevents/http/__init__.py @@ -13,17 +13,25 @@ # under the License. -from cloudevents.http.conversion import ( # noqa - from_dict, - from_http, - from_json, +from cloudevents.http.conversion import from_dict, from_http, from_json +from cloudevents.http.event import CloudEvent +from cloudevents.http.event_type import is_binary, is_structured # deprecated +from cloudevents.http.http_methods import ( # deprecated to_binary, - to_dict, - to_json, + to_binary_http, to_structured, + to_structured_http, ) -from cloudevents.http.event import CloudEvent # noqa -from cloudevents.http.http_methods import to_binary_http # deprecated # noqa -from cloudevents.http.http_methods import to_structured_http # deprecated # noqa -from cloudevents.sdk.converters.binary import is_binary # noqa -from cloudevents.sdk.converters.structured import is_structured # noqa + +__all__ = [ + to_binary, + to_structured, + from_json, + from_http, + from_dict, + CloudEvent, + is_binary, + is_structured, + to_binary_http, + to_structured_http, +] diff --git a/cloudevents/http/conversion.py b/cloudevents/http/conversion.py index e14a13f0..4a5d0a1e 100644 --- a/cloudevents/http/conversion.py +++ b/cloudevents/http/conversion.py @@ -1,9 +1,22 @@ +# Copyright 2018-Present The CloudEvents Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + import typing from cloudevents.conversion import from_dict as _abstract_from_dict from cloudevents.conversion import from_http as _abstract_from_http from cloudevents.conversion import from_json as _abstract_from_json -from cloudevents.conversion import to_binary, to_dict, to_json, to_structured # noqa from cloudevents.http.event import CloudEvent from cloudevents.sdk import types diff --git a/cloudevents/http/http_methods.py b/cloudevents/http/http_methods.py index 3e823e72..9453315d 100644 --- a/cloudevents/http/http_methods.py +++ b/cloudevents/http/http_methods.py @@ -17,9 +17,9 @@ from deprecation import deprecated from cloudevents.abstract import AnyCloudEvent +from cloudevents.conversion import to_binary as _moved_to_binary +from cloudevents.conversion import to_structured as _moved_to_structured from cloudevents.http.conversion import from_http as _moved_from_http -from cloudevents.http.conversion import to_binary as _moved_to_binary -from cloudevents.http.conversion import to_structured as _moved_to_structured from cloudevents.http.event import CloudEvent from cloudevents.sdk import types @@ -28,7 +28,7 @@ @deprecated( deprecated_in="1.6.0", - details="Use cloudevents.http.to_binary function instead", + details="Use cloudevents.conversion.to_binary function instead", ) def to_binary( event: AnyCloudEvent, data_marshaller: types.MarshallerType = None @@ -38,7 +38,7 @@ def to_binary( @deprecated( deprecated_in="1.6.0", - details="Use cloudevents.http.to_structured function instead", + details="Use cloudevents.conversion.to_structured function instead", ) def to_structured( event: AnyCloudEvent, diff --git a/cloudevents/http/json_methods.py b/cloudevents/http/json_methods.py index 82bc41db..f63cede0 100644 --- a/cloudevents/http/json_methods.py +++ b/cloudevents/http/json_methods.py @@ -17,9 +17,9 @@ from deprecation import deprecated from cloudevents.abstract import AnyCloudEvent +from cloudevents.conversion import to_json as _moved_to_json from cloudevents.http import CloudEvent from cloudevents.http.conversion import from_json as _moved_from_json -from cloudevents.http.conversion import to_json as _moved_to_json from cloudevents.sdk import types # THIS MODULE IS DEPRECATED, YOU SHOULD NOT ADD NEW FUNCTIONALLY HERE @@ -27,7 +27,7 @@ @deprecated( deprecated_in="1.6.0", - details="Use cloudevents.http.to_json function instead", + details="Use cloudevents.conversion.to_json function instead", ) def to_json( event: AnyCloudEvent, diff --git a/cloudevents/http/util.py b/cloudevents/http/util.py index 4a3e451e..bdbc61ae 100644 --- a/cloudevents/http/util.py +++ b/cloudevents/http/util.py @@ -13,7 +13,7 @@ # under the License. from deprecation import deprecated -from cloudevents.conversion import ( # noqa +from cloudevents.conversion import ( _best_effort_serialize_to_json as _moved_default_marshaller, ) diff --git a/cloudevents/pydantic/__init__.py b/cloudevents/pydantic/__init__.py index 76962968..84843543 100644 --- a/cloudevents/pydantic/__init__.py +++ b/cloudevents/pydantic/__init__.py @@ -11,13 +11,7 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. -from cloudevents.pydantic.conversion import ( # noqa - from_dict, - from_http, - from_json, - to_binary, - to_dict, - to_json, - to_structured, -) -from cloudevents.pydantic.event import CloudEvent # noqa +from cloudevents.pydantic.conversion import from_dict, from_http, from_json +from cloudevents.pydantic.event import CloudEvent + +__all__ = [CloudEvent, from_json, from_dict, from_http] diff --git a/cloudevents/pydantic/conversion.py b/cloudevents/pydantic/conversion.py index 3710a13d..ab740317 100644 --- a/cloudevents/pydantic/conversion.py +++ b/cloudevents/pydantic/conversion.py @@ -16,7 +16,6 @@ from cloudevents.conversion import from_dict as _abstract_from_dict from cloudevents.conversion import from_http as _abstract_from_http from cloudevents.conversion import from_json as _abstract_from_json -from cloudevents.conversion import to_binary, to_dict, to_json, to_structured # noqa from cloudevents.pydantic.event import CloudEvent from cloudevents.sdk import types diff --git a/cloudevents/pydantic/event.py b/cloudevents/pydantic/event.py index 4184b2d9..be4544d8 100644 --- a/cloudevents/pydantic/event.py +++ b/cloudevents/pydantic/event.py @@ -25,7 +25,6 @@ "Install it using pip install cloudevents[pydantic]" ) -import cloudevents.conversion from cloudevents import abstract, conversion, http from cloudevents.exceptions import IncompatibleArgumentsError from cloudevents.sdk.event import attribute @@ -74,7 +73,7 @@ def _ce_json_loads( """ # Using HTTP from dict due to performance issues. # Pydantic is known for initialization time lagging. - return cloudevents.conversion.to_dict(http.from_json(data)) + return conversion.to_dict(http.from_json(data)) class CloudEvent(abstract.CloudEvent, pydantic.BaseModel): diff --git a/cloudevents/sdk/converters/__init__.py b/cloudevents/sdk/converters/__init__.py index f36015e8..9b78f586 100644 --- a/cloudevents/sdk/converters/__init__.py +++ b/cloudevents/sdk/converters/__init__.py @@ -13,8 +13,10 @@ # under the License. from cloudevents.sdk.converters import binary, structured -from cloudevents.sdk.converters.binary import is_binary # noqa -from cloudevents.sdk.converters.structured import is_structured # noqa +from cloudevents.sdk.converters.binary import is_binary +from cloudevents.sdk.converters.structured import is_structured TypeBinary = binary.BinaryHTTPCloudEventConverter.TYPE TypeStructured = structured.JSONHTTPCloudEventConverter.TYPE + +__all__ = [binary, structured, is_binary, is_structured, TypeBinary, TypeStructured] diff --git a/cloudevents/sdk/converters/util.py b/cloudevents/sdk/converters/util.py index 8dad7330..1ba40544 100644 --- a/cloudevents/sdk/converters/util.py +++ b/cloudevents/sdk/converters/util.py @@ -16,6 +16,11 @@ def has_binary_headers(headers: typing.Dict[str, str]) -> bool: + """Determines if all CloudEvents required headers are presents + in the `headers`. + + :returns: True if all the headers are present, False otherwise. + """ return ( "ce-specversion" in headers and "ce-source" in headers diff --git a/cloudevents/tests/data.py b/cloudevents/tests/data.py index db77aaf5..f5b0ea33 100644 --- a/cloudevents/tests/data.py +++ b/cloudevents/tests/data.py @@ -14,11 +14,11 @@ from cloudevents.sdk.event import v1, v03 -contentType = "application/json" +content_type = "application/json" ce_type = "word.found.exclamation" ce_id = "16fb5f0b-211e-1102-3dfe-ea6e2806f124" source = "pytest" -eventTime = "2018-10-23T12:28:23.3464579Z" +event_time = "2018-10-23T12:28:23.3464579Z" body = '{"name":"john"}' headers = { @@ -26,17 +26,17 @@ "ce-specversion": "1.0", "ce-type": ce_type, "ce-id": ce_id, - "ce-time": eventTime, + "ce-time": event_time, "ce-source": source, - "Content-Type": contentType, + "Content-Type": content_type, }, v1.Event: { "ce-specversion": "1.0", "ce-type": ce_type, "ce-id": ce_id, - "ce-time": eventTime, + "ce-time": event_time, "ce-source": source, - "Content-Type": contentType, + "Content-Type": content_type, }, } @@ -45,16 +45,16 @@ "specversion": "1.0", "type": ce_type, "id": ce_id, - "time": eventTime, + "time": event_time, "source": source, - "datacontenttype": contentType, + "datacontenttype": content_type, }, v1.Event: { "specversion": "1.0", "type": ce_type, "id": ce_id, - "time": eventTime, + "time": event_time, "source": source, - "datacontenttype": contentType, + "datacontenttype": content_type, }, } diff --git a/cloudevents/tests/test_backwards_compatability.py b/cloudevents/tests/test_backwards_compatability.py index 5fb56867..4eaba6e5 100644 --- a/cloudevents/tests/test_backwards_compatability.py +++ b/cloudevents/tests/test_backwards_compatability.py @@ -23,7 +23,8 @@ def dummy_event(): def test_json_methods(dummy_event): - from cloudevents.http import from_json, to_json + from cloudevents.conversion import to_json + from cloudevents.http.conversion import from_json from cloudevents.http.json_methods import from_json as deprecated_from_json from cloudevents.http.json_methods import to_json as deprecated_to_json diff --git a/cloudevents/tests/test_data_encaps_refs.py b/cloudevents/tests/test_data_encaps_refs.py index 3f332633..02405a93 100644 --- a/cloudevents/tests/test_data_encaps_refs.py +++ b/cloudevents/tests/test_data_encaps_refs.py @@ -40,7 +40,7 @@ def test_general_binary_properties(event_class): assert event is not None assert event.type == data.ce_type assert event.id == data.ce_id - assert event.content_type == data.contentType + assert event.content_type == data.content_type assert event.source == data.source # Test setters @@ -80,7 +80,7 @@ def test_general_structured_properties(event_class): assert event is not None assert event.type == data.ce_type assert event.id == data.ce_id - assert event.content_type == data.contentType + assert event.content_type == data.content_type assert event.source == data.source new_headers, _ = m.ToRequest(event, converters.TypeStructured, lambda x: x) diff --git a/cloudevents/tests/test_event_from_request_converter.py b/cloudevents/tests/test_event_from_request_converter.py index 8e8a80be..901284bb 100644 --- a/cloudevents/tests/test_event_from_request_converter.py +++ b/cloudevents/tests/test_event_from_request_converter.py @@ -29,7 +29,7 @@ def test_binary_converter_upstream(event_class): assert event is not None assert event.EventType() == data.ce_type assert event.EventID() == data.ce_id - assert event.ContentType() == data.contentType + assert event.ContentType() == data.content_type @pytest.mark.parametrize("event_class", [v03.Event, v1.Event]) @@ -45,7 +45,7 @@ def test_structured_converter_upstream(event_class): assert event is not None assert event.EventType() == data.ce_type assert event.EventID() == data.ce_id - assert event.ContentType() == data.contentType + assert event.ContentType() == data.content_type @pytest.mark.parametrize("event_class", [v03.Event, v1.Event]) @@ -61,7 +61,7 @@ def test_default_http_marshaller_with_structured(event_class): assert event is not None assert event.EventType() == data.ce_type assert event.EventID() == data.ce_id - assert event.ContentType() == data.contentType + assert event.ContentType() == data.content_type @pytest.mark.parametrize("event_class", [v03.Event, v1.Event]) @@ -77,5 +77,5 @@ def test_default_http_marshaller_with_binary(event_class): assert event is not None assert event.EventType() == data.ce_type assert event.EventID() == data.ce_id - assert event.ContentType() == data.contentType + assert event.ContentType() == data.content_type assert event.Data() == data.body diff --git a/cloudevents/tests/test_event_pipeline.py b/cloudevents/tests/test_event_pipeline.py index a956a198..efc79749 100644 --- a/cloudevents/tests/test_event_pipeline.py +++ b/cloudevents/tests/test_event_pipeline.py @@ -26,11 +26,11 @@ def test_event_pipeline_upstream(event_class): event = ( event_class() - .SetContentType(data.contentType) + .SetContentType(data.content_type) .SetData(data.body) .SetEventID(data.ce_id) .SetSource(data.source) - .SetEventTime(data.eventTime) + .SetEventTime(data.event_time) .SetEventType(data.ce_type) ) m = marshaller.NewDefaultHTTPMarshaller() @@ -74,17 +74,17 @@ def test_object_event_v1(): m = marshaller.NewDefaultHTTPMarshaller() - _, structuredBody = m.ToRequest(event) - assert isinstance(structuredBody, bytes) - structuredObj = json.loads(structuredBody) - errorMsg = f"Body was {structuredBody}, obj is {structuredObj}" - assert isinstance(structuredObj, dict), errorMsg - assert isinstance(structuredObj["data"], dict), errorMsg - assert len(structuredObj["data"]) == 1, errorMsg - assert structuredObj["data"]["name"] == "john", errorMsg + _, structured_body = m.ToRequest(event) + assert isinstance(structured_body, bytes) + structured_obj = json.loads(structured_body) + error_msg = f"Body was {structured_body}, obj is {structured_obj}" + assert isinstance(structured_obj, dict), error_msg + assert isinstance(structured_obj["data"], dict), error_msg + assert len(structured_obj["data"]) == 1, error_msg + assert structured_obj["data"]["name"] == "john", error_msg - headers, binaryBody = m.ToRequest(event, converters.TypeBinary) + headers, binary_body = m.ToRequest(event, converters.TypeBinary) assert isinstance(headers, dict) - assert isinstance(binaryBody, bytes) + assert isinstance(binary_body, bytes) assert headers["content-type"] == "application/json" - assert binaryBody == b'{"name": "john"}', f"Binary is {binaryBody!r}" + assert binary_body == b'{"name": "john"}', f"Binary is {binary_body!r}" diff --git a/cloudevents/tests/test_event_to_request_converter.py b/cloudevents/tests/test_event_to_request_converter.py index 6e58601d..fd25be5a 100644 --- a/cloudevents/tests/test_event_to_request_converter.py +++ b/cloudevents/tests/test_event_to_request_converter.py @@ -33,7 +33,7 @@ def test_binary_event_to_request_upstream(event_class): assert event is not None assert event.EventType() == data.ce_type assert event.EventID() == data.ce_id - assert event.ContentType() == data.contentType + assert event.ContentType() == data.content_type new_headers, _ = m.ToRequest(event, converters.TypeBinary, lambda x: x) assert new_headers is not None @@ -50,7 +50,7 @@ def test_structured_event_to_request_upstream(event_class): assert event is not None assert event.EventType() == data.ce_type assert event.EventID() == data.ce_id - assert event.ContentType() == data.contentType + assert event.ContentType() == data.content_type new_headers, _ = m.ToRequest(event, converters.TypeStructured, lambda x: x) for key in new_headers: diff --git a/cloudevents/tests/test_http_conversions.py b/cloudevents/tests/test_http_conversions.py index 77d8939e..3b9c6717 100644 --- a/cloudevents/tests/test_http_conversions.py +++ b/cloudevents/tests/test_http_conversions.py @@ -18,7 +18,8 @@ import pytest -from cloudevents.http import CloudEvent, from_dict, from_json, to_dict, to_json +from cloudevents.conversion import to_dict, to_json +from cloudevents.http import CloudEvent, from_dict, from_json from cloudevents.sdk.event.attribute import SpecVersion test_data = json.dumps({"data-key": "val"}) diff --git a/cloudevents/tests/test_http_events.py b/cloudevents/tests/test_http_events.py index 6892388d..34f78089 100644 --- a/cloudevents/tests/test_http_events.py +++ b/cloudevents/tests/test_http_events.py @@ -398,10 +398,10 @@ def test_cloudevent_repr(specversion): "ce-source": "", } event = from_http(headers, "") - # Testing to make sure event is printable. I could runevent. __repr__() but + # Testing to make sure event is printable. I could run event. __repr__() but # we had issues in the past where event.__repr__() could run but # print(event) would fail. - print(event) + print(event) # noqa T201 @pytest.mark.parametrize("specversion", ["1.0", "0.3"]) diff --git a/cloudevents/tests/test_pydantic_conversions.py b/cloudevents/tests/test_pydantic_conversions.py index f2722da2..91ab0151 100644 --- a/cloudevents/tests/test_pydantic_conversions.py +++ b/cloudevents/tests/test_pydantic_conversions.py @@ -18,7 +18,8 @@ import pytest -from cloudevents.pydantic import CloudEvent, from_dict, from_json, to_json +from cloudevents.conversion import to_json +from cloudevents.pydantic import CloudEvent, from_dict, from_json from cloudevents.sdk.event.attribute import SpecVersion test_data = json.dumps({"data-key": "val"}) diff --git a/cloudevents/tests/test_pydantic_events.py b/cloudevents/tests/test_pydantic_events.py index 163dc1ad..c0ed37c0 100644 --- a/cloudevents/tests/test_pydantic_events.py +++ b/cloudevents/tests/test_pydantic_events.py @@ -20,7 +20,8 @@ from sanic import Sanic, response import cloudevents.exceptions as cloud_exceptions -from cloudevents.pydantic import CloudEvent, from_http, to_binary, to_structured +from cloudevents.conversion import to_binary, to_structured +from cloudevents.pydantic import CloudEvent, from_http from cloudevents.sdk import converters from cloudevents.sdk.converters.binary import is_binary from cloudevents.sdk.converters.structured import is_structured @@ -81,7 +82,6 @@ async def echo(request): @pytest.mark.parametrize("body", invalid_cloudevent_request_body) def test_missing_required_fields_structured(body): with pytest.raises(cloud_exceptions.MissingRequiredFields): - _ = from_http( {"Content-Type": "application/cloudevents+json"}, json.dumps(body) ) @@ -186,7 +186,6 @@ def test_missing_ce_prefix_binary_event(specversion): "ce-specversion": specversion, } for key in headers: - # breaking prefix e.g. e-id instead of ce-id prefixed_headers[key[1:]] = headers[key] @@ -383,10 +382,10 @@ def test_cloudevent_repr(specversion): "ce-source": "", } event = from_http(headers, "") - # Testing to make sure event is printable. I could runevent. __repr__() but + # Testing to make sure event is printable. I could run event. __repr__() but # we had issues in the past where event.__repr__() could run but # print(event) would fail. - print(event) + print(event) # noqa T201 @pytest.mark.parametrize("specversion", ["1.0", "0.3"]) diff --git a/requirements/dev.txt b/requirements/dev.txt index 264984ac..63872949 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -2,8 +2,6 @@ black isort flake8 pep8-naming -flake8-import-order flake8-print -flake8-strict tox pre-commit diff --git a/requirements/test.txt b/requirements/test.txt index a47dade8..3f6e2d89 100644 --- a/requirements/test.txt +++ b/requirements/test.txt @@ -1,8 +1,6 @@ flake8 pep8-naming -flake8-import-order flake8-print -flake8-strict pytest pytest-cov # web app tests