Skip to content

Commit 841a450

Browse files
authored
PYTHON-4198: Run 'bump-pydantic' (#29)
1 parent ecc3f9b commit 841a450

File tree

3 files changed

+7
-16
lines changed

3 files changed

+7
-16
lines changed

{{cookiecutter.project_slug}}/backend/app/app/schemas/base_schema.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from __future__ import annotations
2-
from pydantic import BaseModel, Field
2+
from pydantic import ConfigDict, BaseModel, Field
33
from typing import Optional
44
from uuid import UUID
55
from datetime import date, datetime
@@ -50,8 +50,4 @@ class MetadataBaseInDBBase(MetadataBaseSchema):
5050
...,
5151
description="Whether the resource is private to team members with appropriate authorisation.",
5252
)
53-
54-
class Config:
55-
# https://github.com/samuelcolvin/pydantic/issues/1334#issuecomment-745434257
56-
# Call PydanticModel.from_orm(dbQuery)
57-
from_attributes = True
53+
model_config = ConfigDict(from_attributes=True)

{{cookiecutter.project_slug}}/backend/app/app/schemas/token.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from typing import Optional
2-
from pydantic import BaseModel
2+
from pydantic import ConfigDict, BaseModel
33
from odmantic import Model, ObjectId
44

55

@@ -17,8 +17,7 @@ class RefreshTokenUpdate(RefreshTokenBase):
1717

1818

1919
class RefreshToken(RefreshTokenUpdate):
20-
class Config:
21-
from_attributes = True
20+
model_config = ConfigDict(from_attributes=True)
2221

2322

2423
class Token(BaseModel):

{{cookiecutter.project_slug}}/backend/app/app/schemas/user.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from typing import Optional
22
from typing_extensions import Annotated
3-
from pydantic import BaseModel, Field, EmailStr, StringConstraints, field_validator
3+
from pydantic import ConfigDict, BaseModel, Field, EmailStr, StringConstraints, field_validator
44
from odmantic import ObjectId
55

66

@@ -32,18 +32,14 @@ class UserUpdate(UserBase):
3232

3333
class UserInDBBase(UserBase):
3434
id: Optional[ObjectId] = None
35-
36-
class Config:
37-
from_attributes = True
35+
model_config = ConfigDict(from_attributes=True)
3836

3937

4038
# Additional properties to return via API
4139
class User(UserInDBBase):
4240
hashed_password: bool = Field(default=False, alias="password")
4341
totp_secret: bool = Field(default=False, alias="totp")
44-
45-
class Config:
46-
populate_by_name = True
42+
model_config = ConfigDict(populate_by_name=True)
4743

4844
@field_validator("hashed_password", mode="before")
4945
def evaluate_hashed_password(cls, hashed_password):

0 commit comments

Comments
 (0)