mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-05-04 04:25:50 +08:00
[gunicorn] Add precise return type for asgi.protocol:BodyReceiver.receive (#15567)
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import asyncio
|
||||
from _typeshed import Incomplete
|
||||
from collections.abc import Iterable
|
||||
from typing import Final
|
||||
from typing import Final, Literal, TypedDict, type_check_only
|
||||
from typing_extensions import NotRequired
|
||||
|
||||
from gunicorn.asgi.parser import CallbackRequest
|
||||
from gunicorn.config import Config
|
||||
@@ -31,6 +31,12 @@ class ASGIResponseInfo:
|
||||
|
||||
def __init__(self, status: str | int, headers: Iterable[tuple[str | bytes, str | bytes]], sent: int) -> None: ...
|
||||
|
||||
@type_check_only
|
||||
class _BodyReceieverReceiveReturnType(TypedDict):
|
||||
type: Literal["http.disconnect", "http.request"]
|
||||
body: NotRequired[bytes]
|
||||
more_body: NotRequired[bool]
|
||||
|
||||
class BodyReceiver:
|
||||
__slots__ = ("_chunks", "_complete", "_body_finished", "_closed", "_waiter", "request", "protocol")
|
||||
request: CallbackRequest
|
||||
@@ -40,7 +46,7 @@ class BodyReceiver:
|
||||
def feed(self, chunk: bytes) -> None: ...
|
||||
def set_complete(self) -> None: ...
|
||||
def signal_disconnect(self) -> None: ...
|
||||
async def receive(self) -> dict[str, Incomplete]: ... # TODO: Use TypedDict
|
||||
async def receive(self) -> _BodyReceieverReceiveReturnType: ...
|
||||
|
||||
class ASGIProtocol(asyncio.Protocol):
|
||||
worker: ASGIWorker
|
||||
|
||||
Reference in New Issue
Block a user