Skip to content

Commit 3dd180e

Browse files
fix: resolve dependabot alerts (#2094)
* fix: resolve dependabot alerts * fix: bump click, httplib2, setuptools to patched versions
1 parent dd2ee8a commit 3dd180e

5 files changed

Lines changed: 145 additions & 124 deletions

File tree

pyproject.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,26 @@ dependencies = [
99
# Run `uv sync --upgrade-package foo` to upgrade indirect dependencies
1010
"aio-pika==9.5.*",
1111
"aiofiles~=24.1.0",
12-
"aiohttp>=3.13.4",
12+
"aiohttp>=3.14.1",
1313
"alembic~=1.16.1",
1414
"asgi-correlation-id~=4.3.4",
1515
"asyncpg~=0.30.0",
1616
"azure-storage-blob==12.25.*",
1717
"bcrypt~=4.3.0",
1818
"boto3~=1.40.60",
19-
"cryptography>=46.0.7",
19+
"cryptography>=48.0.1",
2020
"ddtrace~=3.17.1",
21-
"fastapi==0.124.*",
22-
"fastapi-mail>=1.5.3",
21+
"fastapi>=0.136.0",
22+
"fastapi-mail>=1.6.3",
2323
"firebase-admin==6.9.*",
2424
"httpx==0.28.*",
2525
"jinja2==3.1.*",
2626
"nh3==0.3.*",
2727
"pydantic[email]>=2.0",
28-
"pyjwt>=2.12.0",
28+
"pyjwt>=2.13.0",
2929
"pymongo==4.13.0",
3030
"pyotp~=2.9.0",
31-
"python-multipart>=0.0.26",
31+
"python-multipart>=0.0.31",
3232
"python-slugify==8.0.4",
3333
"redis==5.2.*",
3434
"sentry-sdk~=2.13",

src/apps/shared/test/client.py

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,23 @@ def _get_updated_headers(self, headers: dict | None = None) -> dict:
2828
headers_.update(headers)
2929
return headers_
3030

31+
def _get_json_headers(
32+
self,
33+
headers: dict | None = None,
34+
body: str | None = None,
35+
files: Mapping[str, BytesIO] | None = None,
36+
) -> dict:
37+
"""Headers for a request whose body is serialized JSON.
38+
39+
The body is passed to httpx as raw ``content``, so the JSON content type has to be set
40+
explicitly - Starlette will not parse the body into the endpoint's model without it.
41+
Skipped for multipart requests and when the caller sets the header itself.
42+
"""
43+
headers_ = self._get_updated_headers(headers)
44+
if body is not None and not files and not any(k.lower() == "content-type" for k in headers_):
45+
headers_["Content-Type"] = "application/json"
46+
return headers_
47+
3148
@staticmethod
3249
def _get_body(
3350
data: dict[str, Any] | BaseModel | list[dict[str, Any]] | list[BaseModel] | None = None,
@@ -50,10 +67,11 @@ async def post(
5067
) -> Response:
5168
if query:
5269
url = self._prepare_url(url, query)
70+
body = self._get_body(data)
5371
response = await self.client.post(
5472
url,
55-
content=self._get_body(data),
56-
headers=self._get_updated_headers(headers),
73+
content=body,
74+
headers=self._get_json_headers(headers, body, files),
5775
files=files,
5876
)
5977
return response
@@ -67,10 +85,11 @@ async def put(
6785
) -> Response:
6886
if query:
6987
url = self._prepare_url(url, query)
88+
body = self._get_body(data)
7089
response = await self.client.put(
7190
url,
72-
content=self._get_body(data),
73-
headers=self._get_updated_headers(headers),
91+
content=body,
92+
headers=self._get_json_headers(headers, body),
7493
)
7594
return response
7695

@@ -94,11 +113,12 @@ async def delete(
94113
) -> Response:
95114
if query:
96115
url = self._prepare_url(url, query)
116+
body = self._get_body(data)
97117
response = await self.client.request(
98118
"DELETE",
99119
url,
100-
content=self._get_body(data),
101-
headers=self._get_updated_headers(headers),
120+
content=body,
121+
headers=self._get_json_headers(headers, body),
102122
)
103123
return response
104124

src/infrastructure/app.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
sqlalchemy_database_error_handler,
4848
starlette_http_exception_handler,
4949
)
50-
from infrastructure.lifespan import shutdown, startup
50+
from infrastructure.lifespan import lifespan
5151
from infrastructure.logger import logger
5252

5353
# Declare your routers here
@@ -108,11 +108,9 @@ def create_app():
108108
description=f"Commit id: <b>{settings.commit_id}</b><br>Version: <b>{settings.version}</b>",
109109
default_response_class=ORJSONResponse,
110110
debug=settings.debug,
111+
lifespan=lifespan,
111112
)
112113

113-
app.add_event_handler("startup", startup(app))
114-
app.add_event_handler("shutdown", shutdown(app))
115-
116114
if settings.sentry.dsn:
117115
sentry_sdk.init(dsn=settings.sentry.dsn, traces_sample_rate=1.0)
118116

src/infrastructure/lifespan.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
from contextlib import asynccontextmanager
2+
from typing import AsyncIterator
3+
14
from fastapi import FastAPI
25

36
from broker import broker
@@ -16,15 +19,8 @@ async def shutdown_taskiq() -> None:
1619
await broker.shutdown()
1720

1821

19-
def startup(app: FastAPI):
20-
async def _startup():
21-
await startup_taskiq()
22-
23-
return _startup
24-
25-
26-
def shutdown(app: FastAPI):
27-
async def _shutdown():
28-
await shutdown_taskiq()
29-
30-
return _shutdown
22+
@asynccontextmanager
23+
async def lifespan(app: FastAPI) -> AsyncIterator[None]:
24+
await startup_taskiq()
25+
yield
26+
await shutdown_taskiq()

0 commit comments

Comments
 (0)