Skip to content

Commit

Permalink
Fix minor issues with testing
Browse files Browse the repository at this point in the history
  • Loading branch information
Cito committed Feb 27, 2024
1 parent 206de32 commit 602f7d7
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
2 changes: 2 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@
ignore_references = set(
"""
GNT GT KT T VT
TContext
enum.Enum
traceback
types.TracebackType
Expand All @@ -166,6 +167,7 @@
graphql.execution.execute.StreamRecord
graphql.language.lexer.EscapeSequence
graphql.language.visitor.EnterLeaveVisitor
graphql.type.definition.TContext
graphql.type.schema.InterfaceImplementations
graphql.validation.validation_context.VariableUsage
graphql.validation.rules.known_argument_names.KnownArgumentNamesOnDirectivesRule
Expand Down
15 changes: 10 additions & 5 deletions src/graphql/type/definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

from __future__ import annotations # Python < 3.10

import sys
from enum import Enum
from typing import (
TYPE_CHECKING,
Expand Down Expand Up @@ -555,8 +554,10 @@ def to_kwargs(self) -> GraphQLFieldKwargs:
def __copy__(self) -> GraphQLField: # pragma: no cover
return self.__class__(**self.to_kwargs())

if sys.version_info < (3, 9) or sys.version_info >= (3, 11):
TContext = TypeVar("TContext")

TContext = TypeVar("TContext")

try:

class GraphQLResolveInfo(NamedTuple, Generic[TContext]):
"""Collection of information passed to the resolvers.
Expand All @@ -580,8 +581,11 @@ class GraphQLResolveInfo(NamedTuple, Generic[TContext]):
variable_values: Dict[str, Any]
context: TContext
is_awaitable: Callable[[Any], bool]
else:
class GraphQLResolveInfo(NamedTuple):
except TypeError as error: # pragma: no cover
if "Multiple inheritance with NamedTuple is not supported" not in str(error):
raise # only catch expected error for Python 3.9 and 3.10

class GraphQLResolveInfo(NamedTuple): # type: ignore[no-redef]
"""Collection of information passed to the resolvers.
This is always passed as the first argument to the resolvers.
Expand All @@ -604,6 +608,7 @@ class GraphQLResolveInfo(NamedTuple):
context: Any
is_awaitable: Callable[[Any], bool]


# Note: Contrary to the Javascript implementation of GraphQLFieldResolver,
# the context is passed as part of the GraphQLResolveInfo and any arguments
# are passed individually as keyword arguments.
Expand Down
1 change: 1 addition & 0 deletions tests/execution/test_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,7 @@ class Data:
result = execute_sync(schema, document, Data())
assert result == ({"a": "b"}, None)

@pytest.mark.filterwarnings("ignore:.* was never awaited:RuntimeWarning")
def uses_the_named_operation_if_operation_name_is_provided():
schema = GraphQLSchema(
GraphQLObjectType("Type", {"a": GraphQLField(GraphQLString)})
Expand Down
1 change: 1 addition & 0 deletions tests/execution/test_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@ async def can_disable_stream_using_if_argument():
}

@pytest.mark.asyncio()
@pytest.mark.filterwarnings("ignore:.* was never awaited:RuntimeWarning")
async def does_not_disable_stream_with_null_if_argument():
document = parse(
"query ($shouldStream: Boolean)"
Expand Down

0 comments on commit 602f7d7

Please sign in to comment.