diff --git a/src/quart/app.py b/src/quart/app.py index 5ad5880..2f0b665 100644 --- a/src/quart/app.py +++ b/src/quart/app.py @@ -1037,7 +1037,7 @@ async def handle_exception(self, error: Exception) -> ResponseTypes: """ exc_info = sys.exc_info() await got_request_exception.send_async( - self, _sync_wrapper=self.ensure_async, exception=error + self, _sync_wrapper=self.ensure_async, exception=error # type: ignore ) propagate = self.config["PROPAGATE_EXCEPTIONS"] @@ -1069,7 +1069,7 @@ async def handle_websocket_exception(self, error: Exception) -> ResponseTypes | """ exc_info = sys.exc_info() await got_websocket_exception.send_async( - self, _sync_wrapper=self.ensure_async, exception=error + self, _sync_wrapper=self.ensure_async, exception=error # type: ignore ) propagate = self.config["PROPAGATE_EXCEPTIONS"] @@ -1163,7 +1163,9 @@ async def do_teardown_request( for function in reversed(self.teardown_request_funcs[name]): await self.ensure_async(function)(exc) - await request_tearing_down.send_async(self, _sync_wrapper=self.ensure_async, exc=exc) + await request_tearing_down.send_async( + self, _sync_wrapper=self.ensure_async, exc=exc # type: ignore + ) async def do_teardown_websocket( self, exc: BaseException | None, websocket_context: WebsocketContext | None = None @@ -1181,13 +1183,17 @@ async def do_teardown_websocket( for function in reversed(self.teardown_websocket_funcs[name]): await self.ensure_async(function)(exc) - await websocket_tearing_down.send_async(self, _sync_wrapper=self.ensure_async, exc=exc) + await websocket_tearing_down.send_async( + self, _sync_wrapper=self.ensure_async, exc=exc # type: ignore + ) async def do_teardown_appcontext(self, exc: BaseException | None) -> None: """Teardown the app (context), calling the teardown functions.""" for function in self.teardown_appcontext_funcs: await self.ensure_async(function)(exc) - await appcontext_tearing_down.send_async(self, _sync_wrapper=self.ensure_async, exc=exc) + await appcontext_tearing_down.send_async( + self, _sync_wrapper=self.ensure_async, exc=exc # type: ignore + ) def app_context(self) -> AppContext: """Create and return an app context. @@ -1321,7 +1327,7 @@ async def _wrapper() -> None: async def handle_background_exception(self, error: Exception) -> None: await got_background_exception.send_async( - self, _sync_wrapper=self.ensure_async, exception=error + self, _sync_wrapper=self.ensure_async, exception=error # type: ignore ) self.log_exception(sys.exc_info()) @@ -1424,7 +1430,7 @@ async def full_dispatch_request( omits this argument. """ try: - await request_started.send_async(self, _sync_wrapper=self.ensure_async) + await request_started.send_async(self, _sync_wrapper=self.ensure_async) # type: ignore result: ResponseReturnValue | HTTPException | None result = await self.preprocess_request(request_context) @@ -1444,7 +1450,9 @@ async def full_dispatch_websocket( the Flask convention. """ try: - await websocket_started.send_async(self, _sync_wrapper=self.ensure_async) + await websocket_started.send_async( + self, _sync_wrapper=self.ensure_async # type: ignore + ) result: ResponseReturnValue | HTTPException | None result = await self.preprocess_websocket(websocket_context) @@ -1558,7 +1566,7 @@ async def finalize_request( try: response = await self.process_response(response, request_context) await request_finished.send_async( - self, _sync_wrapper=self.ensure_async, response=response + self, _sync_wrapper=self.ensure_async, response=response # type: ignore ) except Exception: if not from_error_handler: @@ -1586,7 +1594,7 @@ async def finalize_websocket( try: response = await self.postprocess_websocket(response, websocket_context) await websocket_finished.send_async( - self, _sync_wrapper=self.ensure_async, response=response + self, _sync_wrapper=self.ensure_async, response=response # type: ignore ) except Exception: if not from_error_handler: @@ -1693,7 +1701,7 @@ async def startup(self) -> None: await gen.__anext__() except Exception as error: await got_serving_exception.send_async( - self, _sync_wrapper=self.ensure_async, exception=error + self, _sync_wrapper=self.ensure_async, exception=error # type: ignore ) self.log_exception(sys.exc_info()) raise @@ -1721,7 +1729,7 @@ async def shutdown(self) -> None: raise RuntimeError("While serving generator didn't terminate") except Exception as error: await got_serving_exception.send_async( - self, _sync_wrapper=self.ensure_async, exception=error + self, _sync_wrapper=self.ensure_async, exception=error # type: ignore ) self.log_exception(sys.exc_info()) raise diff --git a/src/quart/ctx.py b/src/quart/ctx.py index 5b48adc..1915be1 100644 --- a/src/quart/ctx.py +++ b/src/quart/ctx.py @@ -244,7 +244,9 @@ def copy(self) -> AppContext: async def push(self) -> None: self._cv_tokens.append(_cv_app.set(self)) - await appcontext_pushed.send_async(self.app, _sync_wrapper=self.app.ensure_async) + await appcontext_pushed.send_async( + self.app, _sync_wrapper=self.app.ensure_async # type: ignore + ) async def pop(self, exc: BaseException | None = _sentinel) -> None: # type: ignore try: @@ -259,7 +261,9 @@ async def pop(self, exc: BaseException | None = _sentinel) -> None: # type: ign if ctx is not self: raise AssertionError(f"Popped wrong app context. ({ctx!r} instead of {self!r})") - await appcontext_popped.send_async(self.app, _sync_wrapper=self.app.ensure_async) + await appcontext_popped.send_async( + self.app, _sync_wrapper=self.app.ensure_async # type: ignore + ) async def __aenter__(self) -> AppContext: await self.push() diff --git a/src/quart/sessions.py b/src/quart/sessions.py index 9a15a2e..9df230b 100644 --- a/src/quart/sessions.py +++ b/src/quart/sessions.py @@ -213,7 +213,7 @@ async def save_session( val = self.get_signing_serializer(app).dumps(dict(session)) response.set_cookie( name, - val, # type: ignore + val, expires=expires, httponly=httponly, domain=domain, diff --git a/src/quart/templating.py b/src/quart/templating.py index e51e125..c53874b 100644 --- a/src/quart/templating.py +++ b/src/quart/templating.py @@ -61,11 +61,11 @@ async def render_template_string(source: str, **context: Any) -> str: async def _render(template: Template, context: dict, app: Quart) -> str: await before_render_template.send_async( - app, _sync_wrapper=app.ensure_async, template=template, context=context + app, _sync_wrapper=app.ensure_async, template=template, context=context # type: ignore ) rendered_template = await template.render_async(context) await template_rendered.send_async( - app, _sync_wrapper=app.ensure_async, template=template, context=context + app, _sync_wrapper=app.ensure_async, template=template, context=context # type: ignore ) return rendered_template @@ -115,14 +115,14 @@ async def stream_template_string(source: str, **context: Any) -> AsyncIterator[s async def _stream(app: Quart, template: Template, context: dict[str, Any]) -> AsyncIterator[str]: await before_render_template.send_async( - app, _sync_wrapper=app.ensure_async, template=template, context=context + app, _sync_wrapper=app.ensure_async, template=template, context=context # type: ignore ) async def generate() -> AsyncIterator[str]: async for chunk in template.generate_async(context): yield chunk await template_rendered.send_async( - app, _sync_wrapper=app.ensure_async, template=template, context=context + app, _sync_wrapper=app.ensure_async, template=template, context=context # type: ignore ) # If a request context is active, keep it while generating.