From 1b5e39cea24ad4f5b0411e0122e7dcab18536189 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C4=9Bmec?= Date: Tue, 8 Aug 2023 17:27:51 +0200 Subject: [PATCH] Fix import error for users who don't use pydantic (#3018) --- RELEASE.md | 3 +++ strawberry/ext/mypy_plugin.py | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 RELEASE.md diff --git a/RELEASE.md b/RELEASE.md new file mode 100644 index 0000000000..35f90fbd65 --- /dev/null +++ b/RELEASE.md @@ -0,0 +1,3 @@ +Release type: minor + +Fix import error in `strawberry.ext.mypy_plugin` for users who don't use pydantic. diff --git a/strawberry/ext/mypy_plugin.py b/strawberry/ext/mypy_plugin.py index 10757482f8..0dca642717 100644 --- a/strawberry/ext/mypy_plugin.py +++ b/strawberry/ext/mypy_plugin.py @@ -52,7 +52,6 @@ ) from mypy.typevars import fill_typevars from mypy.util import get_unique_redefinition_name -from strawberry.experimental.pydantic._compat import IS_PYDANTIC_V1 # Backwards compatible with the removal of `TypeVarDef` in mypy 0.920. try: @@ -64,8 +63,11 @@ try: from pydantic.mypy import METADATA_KEY as PYDANTIC_METADATA_KEY from pydantic.mypy import PydanticModelField + + from strawberry.experimental.pydantic._compat import IS_PYDANTIC_V1 except ImportError: PYDANTIC_METADATA_KEY = "" + IS_PYDANTIC_V1 = False if TYPE_CHECKING: