Skip to content

Commit 602f7d7

Browse files
committed
Fix minor issues with testing
1 parent 206de32 commit 602f7d7

File tree

4 files changed

+14
-5
lines changed

4 files changed

+14
-5
lines changed

docs/conf.py

+2
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@
141141
ignore_references = set(
142142
"""
143143
GNT GT KT T VT
144+
TContext
144145
enum.Enum
145146
traceback
146147
types.TracebackType
@@ -166,6 +167,7 @@
166167
graphql.execution.execute.StreamRecord
167168
graphql.language.lexer.EscapeSequence
168169
graphql.language.visitor.EnterLeaveVisitor
170+
graphql.type.definition.TContext
169171
graphql.type.schema.InterfaceImplementations
170172
graphql.validation.validation_context.VariableUsage
171173
graphql.validation.rules.known_argument_names.KnownArgumentNamesOnDirectivesRule

src/graphql/type/definition.py

+10-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
from __future__ import annotations # Python < 3.10
44

5-
import sys
65
from enum import Enum
76
from typing import (
87
TYPE_CHECKING,
@@ -555,8 +554,10 @@ def to_kwargs(self) -> GraphQLFieldKwargs:
555554
def __copy__(self) -> GraphQLField: # pragma: no cover
556555
return self.__class__(**self.to_kwargs())
557556

558-
if sys.version_info < (3, 9) or sys.version_info >= (3, 11):
559-
TContext = TypeVar("TContext")
557+
558+
TContext = TypeVar("TContext")
559+
560+
try:
560561

561562
class GraphQLResolveInfo(NamedTuple, Generic[TContext]):
562563
"""Collection of information passed to the resolvers.
@@ -580,8 +581,11 @@ class GraphQLResolveInfo(NamedTuple, Generic[TContext]):
580581
variable_values: Dict[str, Any]
581582
context: TContext
582583
is_awaitable: Callable[[Any], bool]
583-
else:
584-
class GraphQLResolveInfo(NamedTuple):
584+
except TypeError as error: # pragma: no cover
585+
if "Multiple inheritance with NamedTuple is not supported" not in str(error):
586+
raise # only catch expected error for Python 3.9 and 3.10
587+
588+
class GraphQLResolveInfo(NamedTuple): # type: ignore[no-redef]
585589
"""Collection of information passed to the resolvers.
586590
587591
This is always passed as the first argument to the resolvers.
@@ -604,6 +608,7 @@ class GraphQLResolveInfo(NamedTuple):
604608
context: Any
605609
is_awaitable: Callable[[Any], bool]
606610

611+
607612
# Note: Contrary to the Javascript implementation of GraphQLFieldResolver,
608613
# the context is passed as part of the GraphQLResolveInfo and any arguments
609614
# are passed individually as keyword arguments.

tests/execution/test_executor.py

+1
Original file line numberDiff line numberDiff line change
@@ -638,6 +638,7 @@ class Data:
638638
result = execute_sync(schema, document, Data())
639639
assert result == ({"a": "b"}, None)
640640

641+
@pytest.mark.filterwarnings("ignore:.* was never awaited:RuntimeWarning")
641642
def uses_the_named_operation_if_operation_name_is_provided():
642643
schema = GraphQLSchema(
643644
GraphQLObjectType("Type", {"a": GraphQLField(GraphQLString)})

tests/execution/test_stream.py

+1
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,7 @@ async def can_disable_stream_using_if_argument():
373373
}
374374

375375
@pytest.mark.asyncio()
376+
@pytest.mark.filterwarnings("ignore:.* was never awaited:RuntimeWarning")
376377
async def does_not_disable_stream_with_null_if_argument():
377378
document = parse(
378379
"query ($shouldStream: Boolean)"

0 commit comments

Comments
 (0)