Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: pydantic ^2.9.0 needs 2 extra fields on to_argument #3632

Merged
merged 6 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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",
]
}
4 changes: 4 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Release type: patch

Fix pydantic ^2.9.0 needs 2 extra fields on to_argument
It was causing mypy crash
patrick91 marked this conversation as resolved.
Show resolved Hide resolved
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):
patrick91 marked this conversation as resolved.
Show resolved Hide resolved
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
Loading