From 64e08342de8ddad5c14bd5d66340fd71fbf07bba Mon Sep 17 00:00:00 2001 From: Aaron Harper Date: Sun, 22 Oct 2023 13:02:39 -0400 Subject: [PATCH] Use 80 line length --- inngest/client.py | 8 ++++++-- inngest/comm.py | 12 +++++++++--- inngest/frameworks/flask.py | 3 ++- inngest/time.py | 5 ++++- inngest/transforms_test.py | 6 +++--- inngest/types.py | 4 +++- pyproject.toml | 3 +++ tests/dev_server.py | 26 ++++++++++++++------------ tests/http_proxy.py | 5 ++++- 9 files changed, 48 insertions(+), 24 deletions(-) diff --git a/inngest/client.py b/inngest/client.py index a5d71e3f..24b02a1f 100644 --- a/inngest/client.py +++ b/inngest/client.py @@ -62,11 +62,15 @@ def send(self, events: Event | list[Event]) -> list[str]: res_body: object = res.json() if not isinstance(res_body, dict) or "ids" not in res_body: self.logger.error("unexpected response when sending events") - raise InvalidResponseShape("unexpected response when sending events") + raise InvalidResponseShape( + "unexpected response when sending events" + ) ids = res_body["ids"] if not isinstance(ids, list): self.logger.error("unexpected response when sending events") - raise InvalidResponseShape("unexpected response when sending events") + raise InvalidResponseShape( + "unexpected response when sending events" + ) return ids diff --git a/inngest/comm.py b/inngest/comm.py index 6532e243..f323f774 100644 --- a/inngest/comm.py +++ b/inngest/comm.py @@ -130,7 +130,9 @@ def _parse_registration_response( self, server_res: requests.Response, ) -> CommResponse: - comm_res = CommResponse(headers=create_headers(framework=self._framework)) + comm_res = CommResponse( + headers=create_headers(framework=self._framework) + ) body: dict[str, object] = {} server_res_body: dict[str, object] | None = None @@ -180,7 +182,9 @@ def register( """ if is_from_dev_server and not allow_dev_server(): - self._logger.error("Dev Server registration not allowed in production mode") + self._logger.error( + "Dev Server registration not allowed in production mode" + ) comm_res = CommResponse( headers={}, @@ -209,7 +213,9 @@ def register( headers = create_headers(framework=self._framework) if self._signing_key: - headers["Authorization"] = f"Bearer {hash_signing_key(self._signing_key)}" + headers[ + "Authorization" + ] = f"Bearer {hash_signing_key(self._signing_key)}" res = requests_session.post( registration_url, diff --git a/inngest/frameworks/flask.py b/inngest/frameworks/flask.py index 72192f8a..bf5930e7 100644 --- a/inngest/frameworks/flask.py +++ b/inngest/frameworks/flask.py @@ -44,7 +44,8 @@ def inngest_api() -> Response | str: comm.register( app_url=request.url, # TODO: Find a better way to figure this out. - is_from_dev_server=request.environ["REMOTE_ADDR"] == "127.0.0.1", + is_from_dev_server=request.environ["REMOTE_ADDR"] + == "127.0.0.1", ) ) diff --git a/inngest/time.py b/inngest/time.py index 79d49561..edd16db1 100644 --- a/inngest/time.py +++ b/inngest/time.py @@ -2,4 +2,7 @@ def to_iso_utc(value: datetime) -> str: - return value.astimezone(timezone.utc).strftime("%Y-%m-%dT%H:%M:%S.%f")[:-3] + "Z" + return ( + value.astimezone(timezone.utc).strftime("%Y-%m-%dT%H:%M:%S.%f")[:-3] + + "Z" + ) diff --git a/inngest/transforms_test.py b/inngest/transforms_test.py index 0d68544c..0e1ddd7b 100644 --- a/inngest/transforms_test.py +++ b/inngest/transforms_test.py @@ -2,8 +2,8 @@ def test_hash_signing_key() -> None: - signing_key = ( - "signkey-prod-568c4116828e6e8384a554153722df93022e5cd29a6c2d1b0444a19a807ff315" + signing_key = "signkey-prod-568c4116828e6e8384a554153722df93022e5cd29a6c2d1b0444a19a807ff315" + expectation = ( + "2e64ca0edc850db32ff684f967822c828f99cf57862e43205fdcf2eff8d95180" ) - expectation = "2e64ca0edc850db32ff684f967822c828f99cf57862e43205fdcf2eff8d95180" assert hash_signing_key(signing_key) == expectation diff --git a/inngest/types.py b/inngest/types.py index 4f122a30..97a24085 100644 --- a/inngest/types.py +++ b/inngest/types.py @@ -32,4 +32,6 @@ def to_dict(self) -> dict[str, object]: return dump -TBaseModel = TypeVar("TBaseModel", bound=BaseModel) # pylint: disable=invalid-name +TBaseModel = TypeVar( # pylint: disable=invalid-name + "TBaseModel", bound=BaseModel +) diff --git a/pyproject.toml b/pyproject.toml index 6f6691f2..64c1d0b0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -28,6 +28,9 @@ extra = [ "Homepage" = "https://github.com/inngest/inngest-py" "Bug Tracker" = "https://github.com/inngest/inngest-py/issues" +[tool.black] +line-length = 80 + [tool.isort] profile = "black" diff --git a/tests/dev_server.py b/tests/dev_server.py index 32bbc54a..178a85f1 100644 --- a/tests/dev_server.py +++ b/tests/dev_server.py @@ -45,18 +45,20 @@ def start(self) -> None: stdout = None def _run() -> None: - self._process = subprocess.Popen( # pylint: disable=consider-using-with - [ - "npx", - "inngest-cli@latest", - "dev", - "--no-discovery", - "--no-poll", - "--port", - f"{DEV_SERVER_PORT}", - ], - stderr=stderr, - stdout=stdout, + self._process = ( + subprocess.Popen( # pylint: disable=consider-using-with + [ + "npx", + "inngest-cli@latest", + "dev", + "--no-discovery", + "--no-poll", + "--port", + f"{DEV_SERVER_PORT}", + ], + stderr=stderr, + stdout=stdout, + ) ) self._process.communicate() diff --git a/tests/http_proxy.py b/tests/http_proxy.py index 9a250b04..0727aa3b 100644 --- a/tests/http_proxy.py +++ b/tests/http_proxy.py @@ -94,7 +94,10 @@ def port(self) -> int: return self._port def start(self) -> HTTPProxy: - self._thread = threading.Thread(daemon=True, target=self._server.serve_forever) + self._thread = threading.Thread( + daemon=True, + target=self._server.serve_forever, + ) self._thread.start() return self