Skip to content

Commit

Permalink
fix: pydantic ^2.9.0 needs 2 extra fields on to_argument (#3632)
Browse files Browse the repository at this point in the history
* 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 <patrick.arminio@gmail.com>
  • Loading branch information
3 people authored Sep 26, 2024
1 parent 8e92e2b commit 3eb3b20
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
3 changes: 2 additions & 1 deletion .alexrc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"execution",
"special",
"primitive",
"invalid"
"invalid",
"crash",
]
}
3 changes: 3 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Release type: patch

This releases adds support for Pydantic 2.9.0's Mypy plugin
9 changes: 8 additions & 1 deletion strawberry/ext/mypy_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,14 @@ def strawberry_pydantic_class_callback(ctx: ClassDefContext) -> None:
# Based on pydantic's default value
# https://github.com/pydantic/pydantic/pull/9606/files#diff-469037bbe55bbf9aa359480a16040d368c676adad736e133fb07e5e20d6ac523R1066
extra["force_typevars_invariant"] = False

if PYDANTIC_VERSION >= (2, 9, 0):
extra["model_strict"] = model_type.type.metadata[
PYDANTIC_METADATA_KEY
]["config"].get("strict", False)
extra["is_root_model_root"] = any(
"pydantic.root_model.RootModel" in base.fullname
for base in model_type.type.mro[:-1]
)
add_method(
ctx,
"to_pydantic",
Expand Down

0 comments on commit 3eb3b20

Please sign in to comment.