Skip to content

Commit bf034ca

Browse files
DoctorJohnDaniel Gallagher
and
Daniel Gallagher
authored
Rename variables called type to type_ (#1216)
Co-authored-by: Daniel Gallagher <[email protected]>
1 parent 05d96a9 commit bf034ca

File tree

10 files changed

+38
-36
lines changed

10 files changed

+38
-36
lines changed

docs/relay/nodes.rst

+6-6
Original file line numberDiff line numberDiff line change
@@ -51,20 +51,20 @@ Example of a custom node:
5151
name = 'Node'
5252
5353
@staticmethod
54-
def to_global_id(type, id):
55-
return f"{type}:{id}"
54+
def to_global_id(type_, id):
55+
return f"{type_}:{id}"
5656
5757
@staticmethod
5858
def get_node_from_global_id(info, global_id, only_type=None):
59-
type, id = global_id.split(':')
59+
type_, id = global_id.split(':')
6060
if only_type:
6161
# We assure that the node type that we want to retrieve
6262
# is the same that was indicated in the field type
63-
assert type == only_type._meta.name, 'Received not compatible node.'
63+
assert type_ == only_type._meta.name, 'Received not compatible node.'
6464
65-
if type == 'User':
65+
if type_ == 'User':
6666
return get_user(id)
67-
elif type == 'Photo':
67+
elif type_ == 'Photo':
6868
return get_photo(id)
6969
7070

graphene/pyutils/dataclasses.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -845,7 +845,9 @@ def _process_class(cls, init, repr, eq, order, unsafe_hash, frozen):
845845
# Now find fields in our class. While doing so, validate some
846846
# things, and set the default values (as class attributes) where
847847
# we can.
848-
cls_fields = [_get_field(cls, name, type) for name, type in cls_annotations.items()]
848+
cls_fields = [
849+
_get_field(cls, name, type_) for name, type_ in cls_annotations.items()
850+
]
849851
for f in cls_fields:
850852
fields[f.name] = f
851853

graphene/relay/connection.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -117,19 +117,19 @@ def connection_adapter(cls, edges, pageInfo):
117117

118118

119119
class IterableConnectionField(Field):
120-
def __init__(self, type, *args, **kwargs):
120+
def __init__(self, type_, *args, **kwargs):
121121
kwargs.setdefault("before", String())
122122
kwargs.setdefault("after", String())
123123
kwargs.setdefault("first", Int())
124124
kwargs.setdefault("last", Int())
125-
super(IterableConnectionField, self).__init__(type, *args, **kwargs)
125+
super(IterableConnectionField, self).__init__(type_, *args, **kwargs)
126126

127127
@property
128128
def type(self):
129-
type = super(IterableConnectionField, self).type
130-
connection_type = type
131-
if isinstance(type, NonNull):
132-
connection_type = type.of_type
129+
type_ = super(IterableConnectionField, self).type
130+
connection_type = type_
131+
if isinstance(type_, NonNull):
132+
connection_type = type_.of_type
133133

134134
if is_node(connection_type):
135135
raise Exception(
@@ -140,7 +140,7 @@ def type(self):
140140
assert issubclass(
141141
connection_type, Connection
142142
), f'{self.__class__.__name__} type has to be a subclass of Connection. Received "{connection_type}".'
143-
return type
143+
return type_
144144

145145
@classmethod
146146
def resolve_connection(cls, connection_type, args, resolved):

graphene/relay/node.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,15 @@ def get_resolver(self, parent_resolver):
4747

4848

4949
class NodeField(Field):
50-
def __init__(self, node, type=False, **kwargs):
50+
def __init__(self, node, type_=False, **kwargs):
5151
assert issubclass(node, Node), "NodeField can only operate in Nodes"
5252
self.node_type = node
53-
self.field_type = type
53+
self.field_type = type_
5454

5555
super(NodeField, self).__init__(
5656
# If we don's specify a type, the field type will be the node
5757
# interface
58-
type or node,
58+
type_ or node,
5959
id=ID(required=True, description="The ID of the object"),
6060
**kwargs,
6161
)
@@ -125,5 +125,5 @@ def from_global_id(cls, global_id):
125125
return from_global_id(global_id)
126126

127127
@classmethod
128-
def to_global_id(cls, type, id):
129-
return to_global_id(type, id)
128+
def to_global_id(cls, type_, id):
129+
return to_global_id(type_, id)

graphene/relay/tests/test_node_custom.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class Meta:
1111
name = "Node"
1212

1313
@staticmethod
14-
def to_global_id(type, id):
14+
def to_global_id(type_, id):
1515
return id
1616

1717
@staticmethod

graphene/types/argument.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class Argument(MountedType):
4040

4141
def __init__(
4242
self,
43-
type,
43+
type_,
4444
default_value=None,
4545
description=None,
4646
name=None,
@@ -50,10 +50,10 @@ def __init__(
5050
super(Argument, self).__init__(_creation_counter=_creation_counter)
5151

5252
if required:
53-
type = NonNull(type)
53+
type_ = NonNull(type_)
5454

5555
self.name = name
56-
self._type = type
56+
self._type = type_
5757
self.default_value = default_value
5858
self.description = description
5959

graphene/types/dynamic.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ class Dynamic(MountedType):
1010
the schema. So we can have lazy fields.
1111
"""
1212

13-
def __init__(self, type, with_schema=False, _creation_counter=None):
13+
def __init__(self, type_, with_schema=False, _creation_counter=None):
1414
super(Dynamic, self).__init__(_creation_counter=_creation_counter)
15-
assert inspect.isfunction(type) or isinstance(type, partial)
16-
self.type = type
15+
assert inspect.isfunction(type_) or isinstance(type_, partial)
16+
self.type = type_
1717
self.with_schema = with_schema
1818

1919
def get_type(self, schema=None):

graphene/types/field.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class Person(ObjectType):
6464

6565
def __init__(
6666
self,
67-
type,
67+
type_,
6868
args=None,
6969
resolver=None,
7070
source=None,
@@ -88,7 +88,7 @@ def __init__(
8888
), f'The default value can not be a function but received "{base_type(default_value)}".'
8989

9090
if required:
91-
type = NonNull(type)
91+
type_ = NonNull(type_)
9292

9393
# Check if name is actually an argument of the field
9494
if isinstance(name, (Argument, UnmountedType)):
@@ -101,7 +101,7 @@ def __init__(
101101
source = None
102102

103103
self.name = name
104-
self._type = type
104+
self._type = type_
105105
self.args = to_arguments(args or {}, extra_args)
106106
if source:
107107
resolver = partial(source_resolver, source)

graphene/types/inputfield.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class Person(InputObjectType):
4848

4949
def __init__(
5050
self,
51-
type,
51+
type_,
5252
name=None,
5353
default_value=Undefined,
5454
deprecation_reason=None,
@@ -60,8 +60,8 @@ def __init__(
6060
super(InputField, self).__init__(_creation_counter=_creation_counter)
6161
self.name = name
6262
if required:
63-
type = NonNull(type)
64-
self._type = type
63+
type_ = NonNull(type_)
64+
self._type = type_
6565
self.deprecation_reason = deprecation_reason
6666
self.default_value = default_value
6767
self.description = description

graphene/types/tests/test_definition.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -234,10 +234,10 @@ def test_stringifies_simple_types():
234234
# (InputObjectType, True)
235235
# )
236236

237-
# for type, answer in expected:
238-
# assert is_input_type(type) == answer
239-
# assert is_input_type(GraphQLList(type)) == answer
240-
# assert is_input_type(GraphQLNonNull(type)) == answer
237+
# for type_, answer in expected:
238+
# assert is_input_type(type_) == answer
239+
# assert is_input_type(GraphQLList(type_)) == answer
240+
# assert is_input_type(GraphQLNonNull(type_)) == answer
241241

242242

243243
# def test_identifies_output_types():

0 commit comments

Comments
 (0)