From b71635467d8ae82880adcde73a1bb0504dab4754 Mon Sep 17 00:00:00 2001 From: Tomasz Kramkowski Date: Fri, 24 Feb 2023 22:57:45 +0000 Subject: fix the StartResponse type and make it a protocol --- paste/__init__.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/paste/__init__.py b/paste/__init__.py index 9b052c6..31f86bc 100644 --- a/paste/__init__.py +++ b/paste/__init__.py @@ -1,7 +1,7 @@ from base64 import b64decode, b64encode from functools import wraps from wsgiref.util import request_uri -from typing import Optional, Any +from typing import Optional, Any, Protocol from collections.abc import Callable, Iterable import binascii import traceback @@ -10,7 +10,18 @@ from sqlite3 import Connection from . import db from . import store -StartResponse = Callable[[str, list[tuple[str, str]]], Optional[tuple]] + +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] -- cgit v1.2.3-54-g00ecf