Adapt type annotations to Falcon App type changes

See also: https://falcon.readthedocs.io/en/latest/api/typing.html#generic-app-types
This commit is contained in:
Vytautas Liuolia
2025-11-10 20:09:17 +01:00
parent 303ac42b47
commit 7751f9a6b6

View File

@@ -161,7 +161,7 @@ class APIMiddleware:
def __init__(self, project_dir: Path, environ: Optional[Mapping[str, str]]) -> None: def __init__(self, project_dir: Path, environ: Optional[Mapping[str, str]]) -> None:
self.api = NominatimAPIAsync(project_dir, environ) self.api = NominatimAPIAsync(project_dir, environ)
self.app: Optional[App] = None self.app: Optional[App[Request, Response]] = None
@property @property
def config(self) -> Configuration: def config(self) -> Configuration:
@@ -169,7 +169,7 @@ class APIMiddleware:
""" """
return self.api.config return self.api.config
def set_app(self, app: App) -> None: def set_app(self, app: App[Request, Response]) -> None:
""" Set the Falcon application this middleware is connected to. """ Set the Falcon application this middleware is connected to.
""" """
self.app = app self.app = app
@@ -193,7 +193,7 @@ class APIMiddleware:
def get_application(project_dir: Path, def get_application(project_dir: Path,
environ: Optional[Mapping[str, str]] = None) -> App: environ: Optional[Mapping[str, str]] = None) -> App[Request, Response]:
""" Create a Nominatim Falcon ASGI application. """ Create a Nominatim Falcon ASGI application.
""" """
apimw = APIMiddleware(project_dir, environ) apimw = APIMiddleware(project_dir, environ)
@@ -215,7 +215,7 @@ def get_application(project_dir: Path,
return app return app
def run_wsgi() -> App: def run_wsgi() -> App[Request, Response]:
""" Entry point for uvicorn. """ Entry point for uvicorn.
Make sure uvicorn is run from the project directory. Make sure uvicorn is run from the project directory.