Skip to content

Commit e489967

Browse files
committed
Fix typing issues
1 parent 1a65aa3 commit e489967

File tree

3 files changed

+12
-14
lines changed

3 files changed

+12
-14
lines changed

Diff for: src/graphql/language/parser.py

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
from typing import Callable, Dict, List, Optional, Union, TypeVar, cast
21
from functools import partial
2+
from typing import Callable, Dict, List, Optional, TypeVar, Union, cast
33

4+
from ..error import GraphQLError, GraphQLSyntaxError
45
from .ast import (
56
ArgumentNode,
67
BooleanValueNode,
@@ -24,14 +25,14 @@
2425
InputObjectTypeDefinitionNode,
2526
InputObjectTypeExtensionNode,
2627
InputValueDefinitionNode,
27-
IntValueNode,
2828
InterfaceTypeDefinitionNode,
2929
InterfaceTypeExtensionNode,
30+
IntValueNode,
3031
ListTypeNode,
3132
ListValueNode,
3233
Location,
33-
NameNode,
3434
NamedTypeNode,
35+
NameNode,
3536
NonNullTypeNode,
3637
NullValueNode,
3738
ObjectFieldNode,
@@ -48,6 +49,7 @@
4849
SelectionNode,
4950
SelectionSetNode,
5051
StringValueNode,
52+
Token,
5153
TypeNode,
5254
TypeSystemExtensionNode,
5355
UnionTypeDefinitionNode,
@@ -57,11 +59,9 @@
5759
VariableNode,
5860
)
5961
from .directive_locations import DirectiveLocation
60-
from .ast import Token
6162
from .lexer import Lexer, is_punctuator_token_kind
6263
from .source import Source, is_source
6364
from .token_kind import TokenKind
64-
from ..error import GraphQLError, GraphQLSyntaxError
6565

6666
__all__ = ["parse", "parse_type", "parse_value", "parse_const_value"]
6767

@@ -401,8 +401,9 @@ def parse_field(self) -> FieldNode:
401401
def parse_arguments(self, is_const: bool) -> List[ArgumentNode]:
402402
"""Arguments[Const]: (Argument[?Const]+)"""
403403
item = self.parse_const_argument if is_const else self.parse_argument
404-
item = cast(Callable[[], ArgumentNode], item)
405-
return self.optional_many(TokenKind.PAREN_L, item, TokenKind.PAREN_R)
404+
return self.optional_many(
405+
TokenKind.PAREN_L, cast(Callable[[], ArgumentNode], item), TokenKind.PAREN_R
406+
)
406407

407408
def parse_argument(self, is_const: bool = False) -> ArgumentNode:
408409
"""Argument[Const]: Name : Value[?Const]"""

Diff for: src/graphql/language/visitor.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414

1515
from ..pyutils import inspect, snake_to_camel
1616
from . import ast
17-
18-
from .ast import Node, QUERY_DOCUMENT_KEYS
17+
from .ast import QUERY_DOCUMENT_KEYS, Node
1918

2019
__all__ = [
2120
"Visitor",
@@ -288,7 +287,7 @@ def visit(
288287
else:
289288
stack = Stack(in_array, idx, keys, edits, stack)
290289
in_array = isinstance(node, tuple)
291-
keys = node if in_array else visitor_keys.get(node.kind, ())
290+
keys = node if in_array else visitor_keys.get(node.kind, ()) # type: ignore
292291
idx = -1
293292
edits = []
294293
if parent:

Diff for: tests/execution/test_abstract.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
from pytest import mark
55

6-
from graphql.execution import execute, execute_sync, ExecutionResult
6+
from graphql.execution import ExecutionResult, execute, execute_sync
77
from graphql.language import parse
88
from graphql.type import (
99
GraphQLBoolean,
@@ -40,9 +40,7 @@ async def execute_query(
4040
assert isinstance(schema, GraphQLSchema)
4141
assert isinstance(query, str)
4242
document = parse(query)
43-
result = (execute_sync if sync else execute)(
44-
schema, document, root_value
45-
) # type: ignore
43+
result = (execute_sync if sync else execute)(schema, document, root_value)
4644
if not sync and isawaitable(result):
4745
result = await result
4846
assert isinstance(result, ExecutionResult)

0 commit comments

Comments
 (0)