Skip to content

Commit 2aeffa5

Browse files
committed
Fix mypy issues
1 parent b4e17f0 commit 2aeffa5

File tree

5 files changed

+17
-14
lines changed

5 files changed

+17
-14
lines changed

gql/transport/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33

44
import six
55
from graphql.execution import ExecutionResult
6-
from graphql.language.ast import Node, Document
6+
from graphql.language.ast import Document
77
from promise import Promise
88

99

1010
@six.add_metaclass(abc.ABCMeta)
1111
class Transport:
1212
@abc.abstractmethod
1313
def execute(self, document):
14-
# type: (Union[Node, Document]) -> Union[ExecutionResult, Promise[ExecutionResult]]
14+
# type: (Document) -> Union[ExecutionResult, Promise[ExecutionResult]]
1515
"""Execute the provided document AST for either a remote or local GraphQL Schema.
1616
1717
:param document: GraphQL query as AST Node or Document object.

gql/transport/local_schema.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
from typing import Any, Union
2+
13
from graphql import GraphQLSchema
24
from graphql.execution import ExecutionResult, execute
35
from graphql.language.ast import Document
46
from promise import Promise
57

68
from gql.transport import Transport
7-
from typing import Any, Union
89

910

1011
class LocalSchemaTransport(Transport):
@@ -21,7 +22,7 @@ def __init__(
2122
self.schema = schema
2223

2324
def execute(self, document, *args, **kwargs):
24-
# type: (Document, Any, Any) -> Union[ExecutionResult, Promise[ExecutionResult]]
25+
# type: (Document, *Any, **Any) -> Union[ExecutionResult, Promise[ExecutionResult]]
2526
"""Execute the given document against the configured local schema.
2627
2728
:param document: GraphQL query as AST Node object.

gql/transport/requests.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
from __future__ import absolute_import
22

3+
from typing import Any, Dict, Union
4+
35
import requests
46
from graphql.execution import ExecutionResult
5-
from graphql.language.ast import Node
7+
from graphql.language.ast import Document
68
from graphql.language.printer import print_ast
79
from requests.auth import AuthBase
810
from requests.cookies import RequestsCookieJar
911

1012
from gql.transport import Transport
11-
from typing import Any, Dict, Union
1213

1314

1415
class RequestsHTTPTransport(Transport):
@@ -55,7 +56,7 @@ def __init__(
5556
self.kwargs = kwargs
5657

5758
def execute(self, document, variable_values=None, timeout=None):
58-
# type: (Node, dict, int) -> ExecutionResult
59+
# type: (Document, Dict, int) -> ExecutionResult
5960
"""Execute the provided document AST against the configured remote server.
6061
This uses the requests library to perform a HTTP POST request to the remote server.
6162
@@ -81,7 +82,7 @@ def execute(self, document, variable_values=None, timeout=None):
8182
# Pass kwargs to requests post method
8283
post_args.update(self.kwargs)
8384

84-
response = requests.post(self.url, **post_args)
85+
response = requests.post(self.url, **post_args) # type: ignore
8586
try:
8687
result = response.json()
8788
if not isinstance(result, dict):

tests/starwars/schema.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,16 @@
4242
),
4343
"name": GraphQLField(GraphQLString, description="The name of the character."),
4444
"friends": GraphQLField(
45-
GraphQLList(characterInterface),
45+
GraphQLList(characterInterface), # type: ignore
4646
description="The friends of the character, or an empty list if they have none.",
4747
),
4848
"appearsIn": GraphQLField(
4949
GraphQLList(episodeEnum), description="Which movies they appear in."
5050
),
5151
},
52-
resolve_type=lambda character, *_: humanType
52+
resolve_type=lambda character, *_: humanType # type: ignore
5353
if getHuman(character.id)
54-
else droidType,
54+
else droidType, # type: ignore
5555
)
5656

5757
humanType = GraphQLObjectType(
@@ -136,7 +136,7 @@
136136
"episode": GraphQLArgument(
137137
description="If omitted, returns the hero of the whole saga. If "
138138
"provided, returns the hero of that particular episode.",
139-
type=episodeEnum,
139+
type=episodeEnum, # type: ignore
140140
)
141141
},
142142
resolver=lambda root, info, **args: getHero(args.get("episode")),
@@ -180,7 +180,8 @@
180180
reviewType,
181181
args={
182182
"episode": GraphQLArgument(
183-
description="Episode to create review", type=episodeEnum,
183+
description="Episode to create review",
184+
type=episodeEnum, # type: ignore
184185
),
185186
"review": GraphQLArgument(
186187
description="set alive status", type=reviewInputType,

tests/starwars/test_validation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
from .schema import StarWarsSchema
88

9-
introspection = graphql(StarWarsSchema, introspection_query).data
9+
introspection = graphql(StarWarsSchema, introspection_query).data # type: ignore
1010

1111

1212
@pytest.fixture

0 commit comments

Comments
 (0)