Merge pull request #3874 from vytas7/falcon-4.2-typing

Adapt type annotations to Falcon App type changes
This commit is contained in:
Sarah Hoffmann
2025-11-16 16:12:35 +01:00
committed by GitHub

View File

@@ -7,6 +7,8 @@
""" """
Server implementation using the falcon webserver framework. Server implementation using the falcon webserver framework.
""" """
from __future__ import annotations
from typing import Optional, Mapping, Any, List, cast from typing import Optional, Mapping, Any, List, cast
from pathlib import Path from pathlib import Path
import asyncio import asyncio
@@ -161,7 +163,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 +171,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 +195,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 +217,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.