diff --git a/graphene_pydantic/converters.py b/graphene_pydantic/converters.py index 1e3297c..d5eeb35 100644 --- a/graphene_pydantic/converters.py +++ b/graphene_pydantic/converters.py @@ -7,6 +7,7 @@ import sys import typing as T import uuid +from types import GenericAlias from typing import Type, get_origin import graphene @@ -238,7 +239,11 @@ def find_graphene_type( return registry.get_type_for_model(type_) elif registry and ( isinstance(type_, BaseModel) - or (inspect.isclass(type_) and issubclass(type_, BaseModel)) + or ( + inspect.isclass(type_) + and not isinstance(type_, GenericAlias) + and issubclass(type_, BaseModel) + ) ): # If it's a Pydantic model that hasn't yet been wrapped with a ObjectType, # we can put a placeholder in and request that `resolve_placeholders()` diff --git a/noxfile.py b/noxfile.py index 1f6cd29..8021922 100644 --- a/noxfile.py +++ b/noxfile.py @@ -5,16 +5,30 @@ @session @parametrize( "pydantic", - ("2.0", "2.1", "2.2", "2.3", "2.4"), + ( + (2, 0), + (2, 1), + (2, 2), + (2, 3), + (2, 4), + (2, 5), + (2, 6), + (2, 7), + (2, 8), + (2, 9), + (2, 10), + ), ) -@parametrize("graphene", ("2.1.8", "2.1.9", "3.0", "3.1", "3.2", "3.3")) +@parametrize("graphene", ("2.1.8", "2.1.9", "3.0", "3.1", "3.2", "3.3", "3.4")) def tests(session, pydantic, graphene): - if sys.version_info > (3, 10) and pydantic in ("1.7", "1.8"): + if sys.version_info > (3, 10) and pydantic in ((1, 7), (1, 8)): return session.skip() if sys.version_info > (3, 10) and graphene <= "3": - # Graphene 2.x doesn't support Python 3.11 return session.skip() - session.install(f"pydantic=={pydantic}") + if sys.version_info > (3, 11) and pydantic < (2, 9): + return session.skip() + pydantic_version_string = ".".join([str(n) for n in pydantic]) + session.install(f"pydantic=={pydantic_version_string}") session.install(f"graphene=={graphene}") session.install("pytest", "pytest-cov", ".") session.run( diff --git a/poetry.lock b/poetry.lock index 0f190d0..0245143 100644 --- a/poetry.lock +++ b/poetry.lock @@ -819,5 +819,5 @@ test = ["covdefaults (>=2.3)", "coverage (>=7.2.7)", "coverage-enable-subprocess [metadata] lock-version = "2.0" -python-versions = "^3.7" +python-versions = "^3.8" content-hash = "8f050cd6fce164a7e7f5999ecacd74720ec5b9c6c70d09c2d7e3bcf9349b0330" diff --git a/tests/test_converters.py b/tests/test_converters.py index 6c18450..fbb09b8 100644 --- a/tests/test_converters.py +++ b/tests/test_converters.py @@ -154,6 +154,10 @@ def test_iterables(): field = _convert_field_from_spec("attr", (T.List[int], [1, 2])) assert isinstance(field.type.of_type, graphene.types.List) + if sys.version_info >= (3, 9): + field = _convert_field_from_spec("attr", (list[int], [1, 2])) + assert isinstance(field.type.of_type, graphene.types.List) + field = _convert_field_from_spec("attr", (list, [1, 2])) assert field.type.of_type == graphene.types.List