aboutsummaryrefslogtreecommitdiffstats
path: root/paste/types.py
blob: 0170c17ac1702886ca70f63fbd45b6481a73a728 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from collections.abc import Callable, Iterable
from typing import Any, Optional, Protocol, runtime_checkable


@runtime_checkable
class Closable(Protocol):
    def close(self):
        ...


class StartResponse(Protocol):
    def __call__(
        self,
        status: str,
        headers: list[tuple[str, str]],
        exc_info: Optional[tuple] = ...,
        /,
    ) -> Callable[[bytes], object]:
        ...


Env = dict[str, Any]
App = Callable[[Env, StartResponse], Iterable[bytes]]
Response = Iterable[bytes]

ProtoMiddleware = Callable[[App, Env, StartResponse], Response]
Middleware = Callable[[App], App]