diff --git a/.alexrc b/.alexrc index db2914316a..587b769682 100644 --- a/.alexrc +++ b/.alexrc @@ -11,6 +11,7 @@ "execution", "special", "primitive", - "invalid" + "invalid", + "crash", ] } diff --git a/RELEASE.md b/RELEASE.md new file mode 100644 index 0000000000..9e2deb1dac --- /dev/null +++ b/RELEASE.md @@ -0,0 +1,3 @@ +Release type: patch + +This releases adds support for Pydantic 2.9.0's Mypy plugin diff --git a/strawberry/ext/mypy_plugin.py b/strawberry/ext/mypy_plugin.py index 5d5c3d08ef..77a8a406f0 100644 --- a/strawberry/ext/mypy_plugin.py +++ b/strawberry/ext/mypy_plugin.py @@ -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",