Skip to content

Commit 3595ff9

Browse files
Pydantic v2 (#19071)
Co-authored-by: Andrew Morgan <[email protected]> Co-authored-by: Andrew Morgan <[email protected]>
1 parent 300c555 commit 3595ff9

33 files changed

+422
-1005
lines changed

.github/workflows/tests.yml

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -207,26 +207,6 @@ jobs:
207207
env:
208208
PULL_REQUEST_NUMBER: ${{ github.event.number }}
209209

210-
lint-pydantic:
211-
runs-on: ubuntu-latest
212-
needs: changes
213-
if: ${{ needs.changes.outputs.linting == 'true' }}
214-
215-
steps:
216-
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
217-
with:
218-
ref: ${{ github.event.pull_request.head.sha }}
219-
- name: Install Rust
220-
uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9 # master
221-
with:
222-
toolchain: ${{ env.RUST_VERSION }}
223-
- uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # v2.8.1
224-
- uses: matrix-org/setup-python-poetry@5bbf6603c5c930615ec8a29f1b5d7d258d905aa4 # v2.0.0
225-
with:
226-
poetry-version: "2.1.1"
227-
extras: "all"
228-
- run: poetry run scripts-dev/check_pydantic_models.py
229-
230210
lint-clippy:
231211
runs-on: ubuntu-latest
232212
needs: changes
@@ -341,7 +321,6 @@ jobs:
341321
- lint-mypy
342322
- lint-crlf
343323
- lint-newsfile
344-
- lint-pydantic
345324
- check-sampleconfig
346325
- check-schema-delta
347326
- check-lockfile
@@ -363,7 +342,6 @@ jobs:
363342
lint
364343
lint-mypy
365344
lint-newsfile
366-
lint-pydantic
367345
lint-clippy
368346
lint-clippy-nightly
369347
lint-rust

changelog.d/19071.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Update pydantic to v2.

poetry.lock

Lines changed: 156 additions & 138 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,8 @@ netaddr = ">=0.7.18"
220220
Jinja2 = ">=3.0"
221221
# 3.2.0 updates collections.abc imports to avoid Python 3.10 incompatibility.
222222
bleach = ">=3.2.0"
223-
# We use `assert_never`, which were added in `typing-extensions` 4.1.
224-
typing-extensions = ">=4.1"
223+
# pydantic 2.12 depends on typing-extensions>=4.14.1
224+
typing-extensions = ">=4.14.1"
225225
# We enforce that we have a `cryptography` version that bundles an `openssl`
226226
# with the latest security patches.
227227
cryptography = ">=3.4.7"
@@ -230,9 +230,10 @@ ijson = ">=3.1.4"
230230
matrix-common = "^1.3.0"
231231
# We need packaging.verison.Version(...).major added in 20.0.
232232
packaging = ">=20.0"
233-
# We support pydantic v1 and pydantic v2 via the pydantic.v1 compat module.
234-
# See https://github.com/matrix-org/synapse/issues/15858
235-
pydantic = ">=1.7.4, <3"
233+
pydantic = [
234+
{ version = "~=2.8", python = "<3.14" },
235+
{ version = "~=2.12", python = ">=3.14" },
236+
]
236237

237238
# This is for building the rust components during "poetry install", which
238239
# currently ignores the `build-system.requires` directive (c.f.
@@ -335,8 +336,6 @@ all = [
335336
# can bump versions without having to update the content-hash in the lockfile.
336337
# This helps prevents merge conflicts when running a batch of dependabot updates.
337338
ruff = "0.12.10"
338-
# Type checking only works with the pydantic.v1 compat module from pydantic v2
339-
pydantic = "^2"
340339

341340
# Typechecking
342341
lxml-stubs = ">=0.4.0"

0 commit comments

Comments
 (0)