Skip to content

Commit

Permalink
Use 80 line length
Browse files Browse the repository at this point in the history
  • Loading branch information
amh4r committed Oct 22, 2023
1 parent a5e9184 commit 64e0834
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 24 deletions.
8 changes: 6 additions & 2 deletions inngest/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
12 changes: 9 additions & 3 deletions inngest/comm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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={},
Expand Down Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion inngest/frameworks/flask.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
)
)

Expand Down
5 changes: 4 additions & 1 deletion inngest/time.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
6 changes: 3 additions & 3 deletions inngest/transforms_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 3 additions & 1 deletion inngest/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
26 changes: 14 additions & 12 deletions tests/dev_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
5 changes: 4 additions & 1 deletion tests/http_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 64e0834

Please sign in to comment.