Skip to content

Commit dabe406

Browse files
Smallest possible change to bump to Pydantic 2.x
This leaves in place usage of several Pydantic 1.x-isms, which will need to be excised before Pydantic 3.x can be supported.
1 parent 1de1f7b commit dabe406

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

pyproject.toml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ dependencies = [
1212
"SQLAlchemy[asyncio]<2.1.0,>=2.0.0",
1313
"SQLAlchemy-Utils",
1414
"anyio>=3.0.0,<4",
15-
"pydantic~=1.10.13",
15+
"pydantic~=2.14.6",
1616
"tenacity~=8.0.1",
1717
"sqlapagination",
1818
"exceptiongroup",
@@ -63,7 +63,15 @@ excludes = [
6363
[tool.pytest.ini_options]
6464
addopts = "-rsx --tb=short --loop-scope session"
6565
testpaths = ["tests"]
66-
filterwarnings = ["error"]
66+
filterwarnings = [
67+
"error",
68+
# Several pending fixes to be a well-behaved pydantic 2.0 user
69+
"ignore:.*The `parse_obj` method is deprecated.*:pydantic.warnings.PydanticDeprecatedSince20",
70+
"ignore:.*The `dict` method is deprecated; use `model_dump` instead.*:pydantic.warnings.PydanticDeprecatedSince20",
71+
"ignore:.*Support for class-based `config` is deprecated, use ConfigDict instead.*:pydantic.warnings.PydanticDeprecatedSince20",
72+
"ignore:.*Pydantic V1 style `@root_validator` validators are deprecated.*:pydantic.warnings.PydanticDeprecatedSince20",
73+
"ignore:.*Field .* has conflict with protected namespace \"model_\".*:UserWarning",
74+
]
6775
asyncio_mode = "auto"
6876
py311_task = true
6977
log_cli = true

src/quart_sqlalchemy/config.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ class EngineConfig(ConfigBase):
138138
def default(cls):
139139
return cls(url="sqlite://")
140140

141-
@root_validator
141+
@root_validator(pre=True)
142142
def apply_driver_defaults(cls, values):
143143
url = sa.make_url(values["url"])
144144
driver = url.drivername
@@ -221,15 +221,15 @@ class BindConfig(ConfigBase):
221221
session: SessionmakerOptions = Field(default_factory=SessionmakerOptions.default)
222222
engine: EngineConfig = Field(default_factory=EngineConfig.default)
223223

224-
@root_validator
224+
@root_validator(pre=True)
225225
def validate_dialect(cls, values):
226226
return validate_dialect(cls, values, "sync")
227227

228228

229229
class AsyncBindConfig(BindConfig):
230230
session: AsyncSessionmakerOptions = Field(default_factory=AsyncSessionmakerOptions.default)
231231

232-
@root_validator
232+
@root_validator(pre=True)
233233
def validate_dialect(cls, values):
234234
return validate_dialect(cls, values, "async")
235235

0 commit comments

Comments
 (0)