Skip to content

Commit 2be6077

Browse files
Renovate BotKeeTraxx
authored andcommitted
chore(deps): lock file maintenance
1 parent f929f56 commit 2be6077

7 files changed

Lines changed: 861 additions & 655 deletions

File tree

app/api/wps.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ async def get_drawing(
101101
500: {"model": ErrorResponse},
102102
},
103103
)
104-
async def update_drawing( # noqa: PLR0913
104+
async def update_drawing( # noqa: PLR0913, PLR0917
105105
request: Request,
106106
drawing_id: uuid.UUID,
107107
admin_id: Annotated[

app/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ async def drawing_not_found_handler(_request: Request, exc: DrawingNotFoundError
129129
@app.exception_handler(S3Error)
130130
async def s3_error_handler(_request: Request, exc: S3Error) -> JSONResponse:
131131
"""Handle S3 operation errors with a 500 Internal Server Error response."""
132-
logger.exception("S3 operation failed: %s", exc.message)
132+
logger.error("S3 operation failed: %s", exc.message)
133133
return JSONResponse(status_code=500, content={"detail": "Storage operation failed"})
134134

135135

app/openapi.py

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from functools import lru_cache
1111
from typing import Any
1212

13-
from fastapi import FastAPI, Response
13+
from fastapi import FastAPI, Response, routing
1414
from fastapi.openapi.docs import get_redoc_html, get_swagger_ui_html
1515
from fastapi.openapi.utils import get_openapi
1616
from fastapi.responses import HTMLResponse
@@ -24,14 +24,38 @@
2424
_SPEC_URL = "/openapi.json"
2525

2626

27+
def _iter_routes(app: FastAPI) -> list[Any]:
28+
"""Return the app routes flattened, one entry per operation.
29+
30+
Since FastAPI 0.141 / Starlette 1.6, ``include_router`` stores a single lazy
31+
``_IncludedRouter`` in ``app.routes`` instead of flattening the child routes,
32+
so iterating ``app.routes`` directly no longer yields the individual
33+
``APIRoute`` objects. ``iter_route_contexts`` resolves those into contexts
34+
that expose the effective path and tags (router prefix and tags merged in),
35+
and ``get_openapi`` accepts them in place of routes. Older FastAPI versions
36+
allowed by our version constraint lack that helper but already flatten the
37+
routes, so fall back to plain iteration there.
38+
"""
39+
iter_route_contexts = getattr(routing, "iter_route_contexts", None)
40+
if iter_route_contexts is None: # pragma: no cover - FastAPI < 0.141
41+
return list(app.routes)
42+
return list(iter_route_contexts(app.routes))
43+
44+
45+
def _is_internal(route: Any) -> bool:
46+
"""Return whether a route (or route context) is tagged as internal."""
47+
original = getattr(route, "original_route", route)
48+
return isinstance(original, APIRoute) and INTERNAL_TAG in (getattr(route, "tags", None) or [])
49+
50+
2751
def _remove_422(schema: dict[str, Any]) -> None:
2852
for method_item in schema.get("paths", {}).values():
2953
for param in method_item.values():
3054
param.get("responses", {}).pop("422", None)
3155

3256

3357
def _build_default_schema(app: FastAPI) -> dict[str, Any]:
34-
routes = [r for r in app.routes if not (isinstance(r, APIRoute) and INTERNAL_TAG in r.tags)]
58+
routes = [r for r in _iter_routes(app) if not _is_internal(r)]
3559
tags = [t for t in (app.openapi_tags or []) if t.get("name") != INTERNAL_TAG]
3660
schema = get_openapi(
3761
title=app.title,
@@ -50,7 +74,7 @@ def _build_default_schema(app: FastAPI) -> dict[str, Any]:
5074

5175

5276
def _build_internal_schema(app: FastAPI) -> dict[str, Any]:
53-
routes = [r for r in app.routes if isinstance(r, APIRoute) and INTERNAL_TAG in r.tags]
77+
routes = [r for r in _iter_routes(app) if _is_internal(r)]
5478
tags = [t for t in (app.openapi_tags or []) if t.get("name") == INTERNAL_TAG]
5579
schema = get_openapi(
5680
title=f"{app.title} - Internal",

app/settings.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ def parse_list(cls, v: str | list[str]) -> list[str]:
101101
@lru_cache
102102
def get_settings() -> Settings: # pragma: no cover
103103
"""Return the cached singleton Settings instance."""
104-
return Settings() # ty: ignore[missing-argument] for production we don't pass parameter we use environment variable
104+
# for production we don't pass parameter, we use environment variables
105+
return Settings()
105106

106107

107108
SettingsDep = Annotated[

app/tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def settings(moto_server: str) -> Settings:
4343
# Pydantic will automatically load any .env or .env.default file, so for testing to avoid
4444
# any different test result between CI and local environment (in which .env file can differ)
4545
# we make sure pydantic doesn't load the environment file with `_env_file=None`
46-
_env_file=None, # ty:ignore[unknown-argument]
46+
_env_file=None,
4747
cors_origins=["http://test.com", "https://hello.com"],
4848
cors_origin_regex=r"http://localhost:\d+",
4949
aws_endpoint_url=moto_server,

app/tests/test_drawings_endpoints.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ def test_create_drawing_s3_failure(client: TestClient, valid_kmz_bytes: bytes, s
271271
client=MagicMock(),
272272
bucket=settings.aws_s3_bucket_name,
273273
)
274-
broken_s3.upload_drawing = AsyncMock(side_effect=S3Error("AWS error details here")) # type: ignore # noqa: PGH003
274+
broken_s3.upload_drawing = AsyncMock(side_effect=S3Error("AWS error details here"))
275275

276276
broken_drawings = DrawingsService(s3=broken_s3)
277277

0 commit comments

Comments
 (0)