Skip to content

Commit

Permalink
Fix new Ruff lint rules
Browse files Browse the repository at this point in the history
  • Loading branch information
hoodmane committed Aug 22, 2024
1 parent 75b98f1 commit 3b74be6
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
13 changes: 11 additions & 2 deletions src/pyodide/internal/asgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@
ASGI = {"spec_version": "2.0", "version": "3.0"}


background_tasks = set()


def run_in_background(coro):
fut = ensure_future(coro)
background_tasks.add(fut)
fut.add_done_callback(background_tasks.discard)


@Depends
async def env(request: Request):
return request.scope["env"]
Expand Down Expand Up @@ -78,7 +87,7 @@ async def send(got):
print("Application shutdown complete")
raise RuntimeError(f"Unexpected lifespan event {got['type']}")

ensure_future(
run_in_background(
app(
{
"asgi": ASGI,
Expand Down Expand Up @@ -184,7 +193,7 @@ async def ws_receive():
return received

env = {}
ensure_future(app(request_to_scope(req, env, ws=True), ws_receive, ws_send))
run_in_background(app(request_to_scope(req, env, ws=True), ws_receive, ws_send))

return Response.new(None, status=101, webSocket=client)

Expand Down
2 changes: 1 addition & 1 deletion src/pyodide/internal/patches/httpx.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ async def _send_single_request(self, request: Request) -> Response:
await timer.async_start()

if not isinstance(request.stream, AsyncByteStream):
raise RuntimeError(
raise TypeError(
"Attempted to send an sync request with an AsyncClient instance."
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
"numpy.random.mtrand",
"tempfile",
"aiohttp.http_websocket",
] + RUST_PACKAGES
*RUST_PACKAGES,
]

# Control number of allowed entropy calls.

Expand Down Expand Up @@ -76,7 +77,7 @@ def get_entropy_import_context(name):
# Initial import needs one entropy call to initialize
# std::collections::HashMap hash seed
return rust_package_context
raise Exception(f"Missing context for {name}")
raise RuntimeError(f"Missing context for {name}")


@contextmanager
Expand Down
3 changes: 2 additions & 1 deletion tools/cross/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from argparse import ArgumentParser, Namespace
from dataclasses import dataclass
from pathlib import Path
from sys import exit
from typing import Callable, Optional

CLANG_FORMAT = os.environ.get("CLANG_FORMAT", "clang-format")
Expand Down Expand Up @@ -80,7 +81,7 @@ def check_clang_format() -> None:
exit(1)
except FileNotFoundError:
# Clang-format is not in the PATH
logging.error("clang-format not found in the PATH")
logging.exception("clang-format not found in the PATH")
exit(1)


Expand Down

0 comments on commit 3b74be6

Please sign in to comment.