Skip to content

Commit 2ea5cad

Browse files
committed
refactor: 'dict' is deprecated in Pydantic 2
1 parent 866cdef commit 2ea5cad

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

api/src/common/exceptions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def __init__(
4444
self.extra = extra
4545
self.severity = severity
4646

47-
def dict(self) -> dict[str, int | str | dict[str, Any] | None]:
47+
def to_dict(self) -> dict[str, int | str | dict[str, Any] | None]:
4848
return {
4949
"status": self.status,
5050
"type": self.type,

api/src/common/responses.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
)
1111

1212
responses: dict[int | str, dict[str, Any]] = {
13-
400: {"model": ErrorResponse, "content": {"application/json": {"example": BadRequestException().dict()}}},
13+
400: {"model": ErrorResponse, "content": {"application/json": {"example": BadRequestException().to_dict()}}},
1414
401: {
1515
"model": ErrorResponse,
1616
"content": {
@@ -21,8 +21,11 @@
2121
}
2222
},
2323
},
24-
403: {"model": ErrorResponse, "content": {"application/json": {"example": MissingPrivilegeException().dict()}}},
25-
404: {"model": ErrorResponse, "content": {"application/json": {"example": NotFoundException().dict()}}},
26-
422: {"model": ErrorResponse, "content": {"application/json": {"example": ValidationException().dict()}}},
27-
500: {"model": ErrorResponse, "content": {"application/json": {"example": ApplicationException().dict()}}},
24+
403: {
25+
"model": ErrorResponse,
26+
"content": {"application/json": {"example": MissingPrivilegeException().to_dict()}},
27+
},
28+
404: {"model": ErrorResponse, "content": {"application/json": {"example": NotFoundException().to_dict()}}},
29+
422: {"model": ErrorResponse, "content": {"application/json": {"example": ValidationException().to_dict()}}},
30+
500: {"model": ErrorResponse, "content": {"application/json": {"example": ApplicationException().to_dict()}}},
2831
}

0 commit comments

Comments
 (0)