From fb9cc701d02fc898a8ec61f5acfcc1fceda50cd0 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Sat, 8 Jun 2024 18:10:34 -0400 Subject: [PATCH] Adjust pydantic code to v2. --- etebase_server/fastapi/exceptions.py | 4 ++-- etebase_server/fastapi/routers/authentication.py | 2 +- etebase_server/fastapi/routers/collection.py | 4 ++-- etebase_server/fastapi/routers/invitation.py | 4 ++-- etebase_server/fastapi/routers/member.py | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/etebase_server/fastapi/exceptions.py b/etebase_server/fastapi/exceptions.py index 248558e..2fbb9a1 100644 --- a/etebase_server/fastapi/exceptions.py +++ b/etebase_server/fastapi/exceptions.py @@ -11,7 +11,7 @@ class HttpErrorField(BaseModel): detail: str class Config: - orm_mode = True + from_attributes = True class HttpErrorOut(BaseModel): @@ -20,7 +20,7 @@ class HttpErrorOut(BaseModel): errors: t.Optional[t.List[HttpErrorField]] class Config: - orm_mode = True + from_attributes = True class CustomHttpException(HTTPException): diff --git a/etebase_server/fastapi/routers/authentication.py b/etebase_server/fastapi/routers/authentication.py index e5cfef8..5f1d8bb 100644 --- a/etebase_server/fastapi/routers/authentication.py +++ b/etebase_server/fastapi/routers/authentication.py @@ -76,7 +76,7 @@ class LoginOut(BaseModel): class Authentication(BaseModel): class Config: - keep_untouched = (cached_property,) + ignored_types= (cached_property,) response: bytes signature: bytes diff --git a/etebase_server/fastapi/routers/collection.py b/etebase_server/fastapi/routers/collection.py index b293f03..04fb8cd 100644 --- a/etebase_server/fastapi/routers/collection.py +++ b/etebase_server/fastapi/routers/collection.py @@ -52,7 +52,7 @@ class CollectionItemRevisionInOut(BaseModel): chunks: t.List[ChunkType] class Config: - orm_mode = True + from_attributes = True @classmethod def from_orm_context( @@ -78,7 +78,7 @@ class CollectionItemCommon(BaseModel): class CollectionItemOut(CollectionItemCommon): class Config: - orm_mode = True + from_attributes = True @classmethod def from_orm_context( diff --git a/etebase_server/fastapi/routers/invitation.py b/etebase_server/fastapi/routers/invitation.py index ca7ec23..b5d841b 100644 --- a/etebase_server/fastapi/routers/invitation.py +++ b/etebase_server/fastapi/routers/invitation.py @@ -34,7 +34,7 @@ class UserInfoOut(BaseModel): pubkey: bytes class Config: - orm_mode = True + from_attributes= True @classmethod def from_orm(cls: t.Type["UserInfoOut"], obj: models.UserInfo) -> "UserInfoOut": @@ -67,7 +67,7 @@ class CollectionInvitationOut(CollectionInvitationCommon): fromPubkey: bytes class Config: - orm_mode = True + from_attributes = True @classmethod def from_orm(cls: t.Type["CollectionInvitationOut"], obj: models.CollectionInvitation) -> "CollectionInvitationOut": diff --git a/etebase_server/fastapi/routers/member.py b/etebase_server/fastapi/routers/member.py index 7c6bc51..e913fbf 100644 --- a/etebase_server/fastapi/routers/member.py +++ b/etebase_server/fastapi/routers/member.py @@ -39,7 +39,7 @@ class CollectionMemberOut(BaseModel): accessLevel: models.AccessLevels class Config: - orm_mode = True + from_attributes = True @classmethod def from_orm(cls: t.Type["CollectionMemberOut"], obj: models.CollectionMember) -> "CollectionMemberOut":