|
31 | 31 | Generic, |
32 | 32 | Literal, |
33 | 33 | overload, |
34 | | - TypeVar, |
35 | 34 | ) |
36 | 35 | import warnings |
37 | 36 |
|
38 | 37 | from falcon import app_helpers as helpers |
39 | 38 | from falcon import constants |
40 | 39 | from falcon import responders |
41 | 40 | from falcon import routing |
| 41 | +from falcon._typing import _ExcT |
| 42 | +from falcon._typing import _ReqT |
| 43 | +from falcon._typing import _RespT |
42 | 44 | from falcon._typing import AsgiResponderCallable |
43 | 45 | from falcon._typing import AsgiResponderWsCallable |
44 | | -from falcon._typing import AsgiSinkCallable |
45 | 46 | from falcon._typing import ErrorHandler |
46 | 47 | from falcon._typing import ErrorSerializer |
47 | 48 | from falcon._typing import FindMethod |
|
86 | 87 | ] |
87 | 88 | ) |
88 | 89 |
|
89 | | -_ExcT = TypeVar('_ExcT', bound=Exception) |
90 | | -_ReqT = TypeVar('_ReqT', bound=Request, contravariant=True) |
91 | | -_RespT = TypeVar('_RespT', bound=Response, contravariant=True) |
92 | | - |
93 | 90 |
|
94 | 91 | class App(Generic[_ReqT, _RespT]): |
95 | 92 | '''The main entry point into a Falcon-based WSGI app. |
@@ -268,17 +265,17 @@ def process_response( |
268 | 265 | # NOTE(caselit): this should actually be a protocol of the methods required |
269 | 266 | # by a router, hardcoded to CompiledRouter for convenience for now. |
270 | 267 | _router: routing.CompiledRouter |
271 | | - _serialize_error: ErrorSerializer |
| 268 | + _serialize_error: ErrorSerializer[_ReqT, _RespT] |
272 | 269 | _sink_and_static_routes: tuple[ |
273 | 270 | tuple[ |
274 | 271 | Pattern[str] | routing.StaticRoute, |
275 | | - SinkCallable | AsgiSinkCallable | routing.StaticRoute, |
| 272 | + SinkCallable[_ReqT, _RespT] | routing.StaticRoute, |
276 | 273 | bool, |
277 | 274 | ], |
278 | 275 | ..., |
279 | 276 | ] |
280 | 277 | _sink_before_static_route: bool |
281 | | - _sinks: list[tuple[Pattern[str], SinkCallable | AsgiSinkCallable, Literal[True]]] |
| 278 | + _sinks: list[tuple[Pattern[str], SinkCallable[_ReqT, _RespT], Literal[True]]] |
282 | 279 | _static_routes: list[ |
283 | 280 | tuple[routing.StaticRoute, routing.StaticRoute, Literal[False]] |
284 | 281 | ] |
@@ -1167,7 +1164,7 @@ def _get_responder( |
1167 | 1164 | if m: |
1168 | 1165 | if is_sink: |
1169 | 1166 | params = m.groupdict() # type: ignore[union-attr] |
1170 | | - responder = obj |
| 1167 | + responder = obj # type: ignore[assignment,unused-ignore] |
1171 | 1168 |
|
1172 | 1169 | break |
1173 | 1170 | else: |
@@ -1220,7 +1217,7 @@ def _python_error_handler( |
1220 | 1217 | req.log_error(traceback.format_exc()) |
1221 | 1218 | self._compose_error_response(req, resp, HTTPInternalServerError()) |
1222 | 1219 |
|
1223 | | - def _find_error_handler(self, ex: Exception) -> ErrorHandler | None: |
| 1220 | + def _find_error_handler(self, ex: Exception) -> ErrorHandler[_ReqT, _RespT] | None: |
1224 | 1221 | # NOTE(csojinb): The `__mro__` class attribute returns the method |
1225 | 1222 | # resolution order tuple, i.e. the complete linear inheritance chain |
1226 | 1223 | # ``(type(ex), ..., object)``. For a valid exception class, the last |
|
0 commit comments