diff --git a/RELEASE.md b/RELEASE.md new file mode 100644 index 0000000000..72f506157f --- /dev/null +++ b/RELEASE.md @@ -0,0 +1,5 @@ +Release type: patch + +TypingUnionType import error check is reraised because TypingGenericAlias is checked at the same time which is checked under 3.9 instead of under 3.10 + +Fix by separating TypingUnionType and TypingGenericAlias imports in their own try-catch diff --git a/noxfile.py b/noxfile.py index 8998473692..c33cb0b0da 100644 --- a/noxfile.py +++ b/noxfile.py @@ -104,7 +104,7 @@ def tests_integrations(session: Session, integration: str) -> None: session.run("pytest", *COMMON_PYTEST_OPTIONS, "-m", integration) -@session(python=["3.11"], name="Pydantic tests", tags=["tests"]) +@session(python=PYTHON_VERSIONS, name="Pydantic tests", tags=["tests"]) @nox.parametrize("pydantic", ["1.10", "2.0.3"]) def test_pydantic(session: Session, pydantic: str) -> None: session.run_always("poetry", "install", external=True) diff --git a/strawberry/experimental/pydantic/fields.py b/strawberry/experimental/pydantic/fields.py index 8ef4417c0e..c85d1c3852 100644 --- a/strawberry/experimental/pydantic/fields.py +++ b/strawberry/experimental/pydantic/fields.py @@ -22,6 +22,15 @@ try: from types import UnionType as TypingUnionType +except ImportError: + import sys + + if sys.version_info < (3, 10): + TypingUnionType = () + else: + raise + +try: from typing import GenericAlias as TypingGenericAlias # type: ignore except ImportError: import sys @@ -32,10 +41,6 @@ TypingGenericAlias = () else: raise - if sys.version_info < (3, 10): - TypingUnionType = () - else: - raise ATTR_TO_TYPE_MAP = { "NoneStr": Optional[str],