Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
7 changes: 6 additions & 1 deletion graphene_pydantic/converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import sys
import typing as T
import uuid
from types import GenericAlias
from typing import Type, get_origin

import graphene
Expand Down Expand Up @@ -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()`
Expand Down
24 changes: 19 additions & 5 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions tests/test_converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Loading