aboutsummaryrefslogtreecommitdiffstats
path: root/paste/types.py
blob: 69d9a21a2d31eaf8099218f5b8c76a52c46720d9 (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[Any, Any, Any]] = ...,
        /,
    ) -> 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]