Skip to content

Commit 01735b1

Browse files
author
Daniel Gallagher
committed
is a builtin in python; switch some arguments called to be
1 parent 28f6353 commit 01735b1

File tree

8 files changed

+156
-155
lines changed

8 files changed

+156
-155
lines changed

UPGRADE-v2.0.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ Before:
207207
```python
208208
class SomeMutation(Mutation):
209209
...
210-
210+
211211
@classmethod
212212
def mutate(cls, instance, args, context, info):
213213
...
@@ -218,7 +218,7 @@ With 2.0:
218218
```python
219219
class SomeMutation(Mutation):
220220
...
221-
221+
222222
def mutate(self, info, **args):
223223
...
224224
```
@@ -231,7 +231,7 @@ class SomeMutation(Mutation):
231231
first_name = String(required=True)
232232
last_name = String(required=True)
233233
...
234-
234+
235235
def mutate(self, info, first_name, last_name):
236236
...
237237
```
@@ -250,7 +250,7 @@ If you are using Middelwares, you need to some adjustments:
250250
Before:
251251

252252
```python
253-
class MyGrapheneMiddleware(object):
253+
class MyGrapheneMiddleware(object):
254254
def resolve(self, next_mw, root, args, context, info):
255255

256256
## Middleware code
@@ -261,7 +261,7 @@ class MyGrapheneMiddleware(object):
261261
With 2.0:
262262

263263
```python
264-
class MyGrapheneMiddleware(object):
264+
class MyGrapheneMiddleware(object):
265265
def resolve(self, next_mw, root, info, **args):
266266
context = info.context
267267

graphene/types/argument.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99

1010
class Argument(MountedType):
1111

12-
def __init__(self, type, default_value=None, description=None, name=None, required=False, _creation_counter=None):
12+
def __init__(self, type_, default_value=None, description=None, name=None, required=False, _creation_counter=None):
1313
super(Argument, self).__init__(_creation_counter=_creation_counter)
1414

1515
if required:
16-
type = NonNull(type)
16+
type_ = NonNull(type_)
1717

1818
self.name = name
19-
self._type = type
19+
self._type = type_
2020
self.default_value = default_value
2121
self.description = description
2222

graphene/types/dynamic.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ class Dynamic(MountedType):
99
the schema. So we can have lazy fields.
1010
'''
1111

12-
def __init__(self, type, with_schema=False, _creation_counter=None):
12+
def __init__(self, type_, with_schema=False, _creation_counter=None):
1313
super(Dynamic, self).__init__(_creation_counter=_creation_counter)
14-
assert inspect.isfunction(type)
15-
self.type = type
14+
assert inspect.isfunction(type_)
15+
self.type = type_
1616
self.with_schema = with_schema
1717

1818
def get_type(self, schema=None):

graphene/types/field.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def source_resolver(source, root, info, **args):
2020

2121
class Field(MountedType):
2222

23-
def __init__(self, type, args=None, resolver=None, source=None,
23+
def __init__(self, type_, args=None, resolver=None, source=None,
2424
deprecation_reason=None, name=None, description=None,
2525
required=False, _creation_counter=None, default_value=None,
2626
**extra_args):
@@ -36,7 +36,7 @@ def __init__(self, type, args=None, resolver=None, source=None,
3636
).format(base_type(default_value))
3737

3838
if required:
39-
type = NonNull(type)
39+
type_ = NonNull(type_)
4040

4141
# Check if name is actually an argument of the field
4242
if isinstance(name, (Argument, UnmountedType)):
@@ -49,7 +49,7 @@ def __init__(self, type, args=None, resolver=None, source=None,
4949
source = None
5050

5151
self.name = name
52-
self._type = type
52+
self._type = type_
5353
self.args = to_arguments(args or OrderedDict(), extra_args)
5454
if source:
5555
resolver = partial(source_resolver, source)

graphene/types/inputfield.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55

66
class InputField(MountedType):
77

8-
def __init__(self, type, name=None, default_value=None,
8+
def __init__(self, type_, name=None, default_value=None,
99
deprecation_reason=None, description=None,
1010
required=False, _creation_counter=None, **extra_args):
1111
super(InputField, self).__init__(_creation_counter=_creation_counter)
1212
self.name = name
1313
if required:
14-
type = NonNull(type)
15-
self._type = type
14+
type_ = NonNull(type_)
15+
self._type = type_
1616
self.deprecation_reason = deprecation_reason
1717
self.default_value = default_value
1818
self.description = description

graphene/types/schema.py

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@
1212
from .typemap import TypeMap, is_graphene_type
1313

1414

15-
def assert_valid_root_type(_type):
16-
if _type is None:
15+
def assert_valid_root_type(type_):
16+
if type_ is None:
1717
return
1818
is_graphene_objecttype = inspect.isclass(
19-
_type) and issubclass(_type, ObjectType)
20-
is_graphql_objecttype = isinstance(_type, GraphQLObjectType)
19+
type_) and issubclass(type_, ObjectType)
20+
is_graphql_objecttype = isinstance(type_, GraphQLObjectType)
2121
assert is_graphene_objecttype or is_graphql_objecttype, (
2222
"Type {} is not a valid ObjectType."
23-
).format(_type)
23+
).format(type_)
2424

2525

2626
class Schema(GraphQLSchema):
@@ -72,26 +72,26 @@ def __getattr__(self, type_name):
7272
7373
Example: using schema.Query for accessing the "Query" type in the Schema
7474
'''
75-
_type = super(Schema, self).get_type(type_name)
76-
if _type is None:
75+
type_ = super(Schema, self).get_type(type_name)
76+
if type_ is None:
7777
raise AttributeError(
7878
'Type "{}" not found in the Schema'.format(type_name))
79-
if isinstance(_type, GrapheneGraphQLType):
80-
return _type.graphene_type
81-
return _type
82-
83-
def get_graphql_type(self, _type):
84-
if not _type:
85-
return _type
86-
if is_type(_type):
87-
return _type
88-
if is_graphene_type(_type):
89-
graphql_type = self.get_type(_type._meta.name)
79+
if isinstance(type_, GrapheneGraphQLType):
80+
return type_.graphene_type
81+
return type_
82+
83+
def get_graphql_type(self, type_):
84+
if not type_:
85+
return type_
86+
if is_type(type_):
87+
return type_
88+
if is_graphene_type(type_):
89+
graphql_type = self.get_type(type_._meta.name)
9090
assert graphql_type, "Type {} not found in this schema.".format(
91-
_type._meta.name)
92-
assert graphql_type.graphene_type == _type
91+
type_._meta.name)
92+
assert graphql_type.graphene_type == type_
9393
return graphql_type
94-
raise Exception("{} is not a valid GraphQL type.".format(_type))
94+
raise Exception("{} is not a valid GraphQL type.".format(type_))
9595

9696
def execute(self, *args, **kwargs):
9797
return graphql(self, *args, **kwargs)
@@ -105,8 +105,8 @@ def introspect(self):
105105
def __str__(self):
106106
return print_schema(self)
107107

108-
def lazy(self, _type):
109-
return lambda: self.get_type(_type)
108+
def lazy(self, type_):
109+
return lambda: self.get_type(type_)
110110

111111
def build_typemap(self):
112112
initial_types = [

0 commit comments

Comments
 (0)