Skip to content

Rename variables called type to type_ #1216

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions docs/relay/nodes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,20 @@ Example of a custom node:
name = 'Node'

@staticmethod
def to_global_id(type, id):
return f"{type}:{id}"
def to_global_id(type_, id):
return f"{type_}:{id}"

@staticmethod
def get_node_from_global_id(info, global_id, only_type=None):
type, id = global_id.split(':')
type_, id = global_id.split(':')
if only_type:
# We assure that the node type that we want to retrieve
# is the same that was indicated in the field type
assert type == only_type._meta.name, 'Received not compatible node.'
assert type_ == only_type._meta.name, 'Received not compatible node.'

if type == 'User':
if type_ == 'User':
return get_user(id)
elif type == 'Photo':
elif type_ == 'Photo':
return get_photo(id)


Expand Down
4 changes: 3 additions & 1 deletion graphene/pyutils/dataclasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -845,7 +845,9 @@ def _process_class(cls, init, repr, eq, order, unsafe_hash, frozen):
# Now find fields in our class. While doing so, validate some
# things, and set the default values (as class attributes) where
# we can.
cls_fields = [_get_field(cls, name, type) for name, type in cls_annotations.items()]
cls_fields = [
_get_field(cls, name, type_) for name, type_ in cls_annotations.items()
]
for f in cls_fields:
fields[f.name] = f

Expand Down
14 changes: 7 additions & 7 deletions graphene/relay/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,19 +117,19 @@ def connection_adapter(cls, edges, pageInfo):


class IterableConnectionField(Field):
def __init__(self, type, *args, **kwargs):
def __init__(self, type_, *args, **kwargs):
kwargs.setdefault("before", String())
kwargs.setdefault("after", String())
kwargs.setdefault("first", Int())
kwargs.setdefault("last", Int())
super(IterableConnectionField, self).__init__(type, *args, **kwargs)
super(IterableConnectionField, self).__init__(type_, *args, **kwargs)

@property
def type(self):
type = super(IterableConnectionField, self).type
connection_type = type
if isinstance(type, NonNull):
connection_type = type.of_type
type_ = super(IterableConnectionField, self).type
connection_type = type_
if isinstance(type_, NonNull):
connection_type = type_.of_type

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

@classmethod
def resolve_connection(cls, connection_type, args, resolved):
Expand Down
10 changes: 5 additions & 5 deletions graphene/relay/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ def get_resolver(self, parent_resolver):


class NodeField(Field):
def __init__(self, node, type=False, **kwargs):
def __init__(self, node, type_=False, **kwargs):
assert issubclass(node, Node), "NodeField can only operate in Nodes"
self.node_type = node
self.field_type = type
self.field_type = type_

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

@classmethod
def to_global_id(cls, type, id):
return to_global_id(type, id)
def to_global_id(cls, type_, id):
return to_global_id(type_, id)
2 changes: 1 addition & 1 deletion graphene/relay/tests/test_node_custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Meta:
name = "Node"

@staticmethod
def to_global_id(type, id):
def to_global_id(type_, id):
return id

@staticmethod
Expand Down
6 changes: 3 additions & 3 deletions graphene/types/argument.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class Argument(MountedType):

def __init__(
self,
type,
type_,
default_value=None,
description=None,
name=None,
Expand All @@ -50,10 +50,10 @@ def __init__(
super(Argument, self).__init__(_creation_counter=_creation_counter)

if required:
type = NonNull(type)
type_ = NonNull(type_)

self.name = name
self._type = type
self._type = type_
self.default_value = default_value
self.description = description

Expand Down
6 changes: 3 additions & 3 deletions graphene/types/dynamic.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ class Dynamic(MountedType):
the schema. So we can have lazy fields.
"""

def __init__(self, type, with_schema=False, _creation_counter=None):
def __init__(self, type_, with_schema=False, _creation_counter=None):
super(Dynamic, self).__init__(_creation_counter=_creation_counter)
assert inspect.isfunction(type) or isinstance(type, partial)
self.type = type
assert inspect.isfunction(type_) or isinstance(type_, partial)
self.type = type_
self.with_schema = with_schema

def get_type(self, schema=None):
Expand Down
6 changes: 3 additions & 3 deletions graphene/types/field.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class Person(ObjectType):

def __init__(
self,
type,
type_,
args=None,
resolver=None,
source=None,
Expand All @@ -88,7 +88,7 @@ def __init__(
), f'The default value can not be a function but received "{base_type(default_value)}".'

if required:
type = NonNull(type)
type_ = NonNull(type_)

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

self.name = name
self._type = type
self._type = type_
self.args = to_arguments(args or {}, extra_args)
if source:
resolver = partial(source_resolver, source)
Expand Down
6 changes: 3 additions & 3 deletions graphene/types/inputfield.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class Person(InputObjectType):

def __init__(
self,
type,
type_,
name=None,
default_value=Undefined,
deprecation_reason=None,
Expand All @@ -60,8 +60,8 @@ def __init__(
super(InputField, self).__init__(_creation_counter=_creation_counter)
self.name = name
if required:
type = NonNull(type)
self._type = type
type_ = NonNull(type_)
self._type = type_
self.deprecation_reason = deprecation_reason
self.default_value = default_value
self.description = description
Expand Down
8 changes: 4 additions & 4 deletions graphene/types/tests/test_definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,10 @@ def test_stringifies_simple_types():
# (InputObjectType, True)
# )

# for type, answer in expected:
# assert is_input_type(type) == answer
# assert is_input_type(GraphQLList(type)) == answer
# assert is_input_type(GraphQLNonNull(type)) == answer
# for type_, answer in expected:
# assert is_input_type(type_) == answer
# assert is_input_type(GraphQLList(type_)) == answer
# assert is_input_type(GraphQLNonNull(type_)) == answer


# def test_identifies_output_types():
Expand Down