Skip to content

Commit ed6cd40

Browse files
committed
Minor tweaks to recent commits
1 parent 3a01656 commit ed6cd40

File tree

4 files changed

+11
-7
lines changed

4 files changed

+11
-7
lines changed

src/hypercorn/protocol/h3.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ async def stream_send(self, event: StreamEvent) -> None:
8686
self.connection.send_headers(event.stream_id, event.headers)
8787
await self.send()
8888
elif isinstance(event, StreamClosed):
89-
# Remove a stream when it's closed to avoid memory leaks
9089
self.streams.pop(event.stream_id, None)
9190
elif isinstance(event, Request):
9291
await self._create_server_push(event.stream_id, event.raw_path, event.headers)

src/hypercorn/protocol/http_stream.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ async def handle(self, event: Event) -> None:
9797
"headers": event.headers,
9898
"client": self.client,
9999
"server": self.server,
100-
"state": event.state.copy(),
100+
"state": event.state.copy(), # type: ignore[typeddict-item]
101101
"extensions": {},
102102
}
103103

src/hypercorn/protocol/ws_stream.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ async def handle(self, event: Event) -> None:
219219
"headers": event.headers,
220220
"client": self.client,
221221
"server": self.server,
222-
"state": event.state.copy(),
222+
"state": event.state.copy(), # type: ignore[typeddict-item]
223223
"subprotocols": self.handshake.subprotocols or [],
224224
"extensions": {"websocket.http.response": {}},
225225
}

tests/e2e/test_httpx.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import hypercorn.trio
88
from hypercorn.config import Config
9+
from hypercorn.typing import ASGIReceiveCallable, ASGISendCallable, Scope
910

1011

1112
async def app(scope, receive, send) -> None: # type: ignore
@@ -58,24 +59,28 @@ async def serve() -> None:
5859

5960

6061
@pytest.mark.trio
61-
async def test_handle_isolate_state():
62+
async def test_handle_isolate_state() -> None:
6263
config = Config()
6364
config.bind = ["0.0.0.0:1234"]
6465
config.accesslog = "-" # Log to stdout/err
6566
config.errorlog = "-"
6667

67-
async def app(scope, receive, send):
68+
async def app(scope: Scope, receive: ASGIReceiveCallable, send: ASGISendCallable) -> None:
6869
assert scope["type"] == "http"
6970

7071
await send(
7172
{
7273
"type": "http.response.start",
7374
"status": 200,
74-
"headers": [[b"content-type", b"text/plain"]],
75+
"headers": [(b"content-type", b"text/plain")],
7576
}
7677
)
7778
await send(
78-
{"type": "http.response.body", "body": scope["state"].get("key", b"")}
79+
{
80+
"type": "http.response.body",
81+
"body": scope["state"].get("key", b""),
82+
"more_body": False,
83+
}
7984
)
8085
scope["state"]["key"] = b"one"
8186

0 commit comments

Comments
 (0)