1 # Types to support PEP 3333 (WSGI)
3 # See the README.md file in this directory for more information.
5 from sys import _OptExcInfo
6 from typing import Any, Callable, Dict, Iterable, Protocol
9 class StartResponse(Protocol):
11 self, status: str, headers: list[tuple[str, str]], exc_info: _OptExcInfo | None = ...
12 ) -> Callable[[bytes], Any]: ...
14 WSGIEnvironment = Dict[str, Any] # stable
15 WSGIApplication = Callable[[WSGIEnvironment, StartResponse], Iterable[bytes]] # stable
17 # WSGI input streams per PEP 3333, stable
18 class InputStream(Protocol):
19 def read(self, size: int = ...) -> bytes: ...
20 def readline(self, size: int = ...) -> bytes: ...
21 def readlines(self, hint: int = ...) -> list[bytes]: ...
22 def __iter__(self) -> Iterable[bytes]: ...
24 # WSGI error streams per PEP 3333, stable
25 class ErrorStream(Protocol):
26 def flush(self) -> None: ...
27 def write(self, s: str) -> None: ...
28 def writelines(self, seq: list[str]) -> None: ...
30 class _Readable(Protocol):
31 def read(self, size: int = ...) -> bytes: ...
33 # Optional file wrapper in wsgi.file_wrapper
34 class FileWrapper(Protocol):
35 def __call__(self, file: _Readable, block_size: int = ...) -> Iterable[bytes]: ...