Skip to content

Commit 3eb3b20

Browse files
chrisemkepre-commit-ci[bot]patrick91
authored
fix: pydantic ^2.9.0 needs 2 extra fields on to_argument (#3632)
* fix: pydantic ^2.9.0 needs 2 extra fields on to_argument * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * docs: add RELEASE.md file * Update .alexrc to allow crash * Update RELEASE.md --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Patrick Arminio <[email protected]>
1 parent 8e92e2b commit 3eb3b20

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

.alexrc

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"execution",
1212
"special",
1313
"primitive",
14-
"invalid"
14+
"invalid",
15+
"crash",
1516
]
1617
}

RELEASE.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Release type: patch
2+
3+
This releases adds support for Pydantic 2.9.0's Mypy plugin

strawberry/ext/mypy_plugin.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,14 @@ def strawberry_pydantic_class_callback(ctx: ClassDefContext) -> None:
481481
# Based on pydantic's default value
482482
# https://github.com/pydantic/pydantic/pull/9606/files#diff-469037bbe55bbf9aa359480a16040d368c676adad736e133fb07e5e20d6ac523R1066
483483
extra["force_typevars_invariant"] = False
484-
484+
if PYDANTIC_VERSION >= (2, 9, 0):
485+
extra["model_strict"] = model_type.type.metadata[
486+
PYDANTIC_METADATA_KEY
487+
]["config"].get("strict", False)
488+
extra["is_root_model_root"] = any(
489+
"pydantic.root_model.RootModel" in base.fullname
490+
for base in model_type.type.mro[:-1]
491+
)
485492
add_method(
486493
ctx,
487494
"to_pydantic",

0 commit comments

Comments
 (0)