Skip to content

"type" is a builtin in python; switch some arguments called "type" to be "type_" #738

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

Closed
Closed
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
6 changes: 3 additions & 3 deletions graphene/types/argument.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@

class Argument(MountedType):

def __init__(self, type, default_value=None, description=None, name=None, required=False, _creation_counter=None):
def __init__(self, type_, default_value=None, description=None, name=None, required=False, _creation_counter=None):
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 @@ -20,7 +20,7 @@ def source_resolver(source, root, info, **args):

class Field(MountedType):

def __init__(self, type, args=None, resolver=None, source=None,
def __init__(self, type_, args=None, resolver=None, source=None,
deprecation_reason=None, name=None, description=None,
required=False, _creation_counter=None, default_value=None,
**extra_args):
Expand All @@ -36,7 +36,7 @@ def __init__(self, type, args=None, resolver=None, source=None,
).format(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 @@ -49,7 +49,7 @@ def __init__(self, type, args=None, resolver=None, source=None,
source = None

self.name = name
self._type = type
self._type = type_
self.args = to_arguments(args or OrderedDict(), 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 @@ -5,14 +5,14 @@

class InputField(MountedType):

def __init__(self, type, name=None, default_value=None,
def __init__(self, type_, name=None, default_value=None,
deprecation_reason=None, description=None,
required=False, _creation_counter=None, **extra_args):
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
46 changes: 23 additions & 23 deletions graphene/types/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
from .typemap import TypeMap, is_graphene_type


def assert_valid_root_type(_type):
if _type is None:
def assert_valid_root_type(type_):
if type_ is None:
return
is_graphene_objecttype = inspect.isclass(
_type) and issubclass(_type, ObjectType)
is_graphql_objecttype = isinstance(_type, GraphQLObjectType)
type_) and issubclass(type_, ObjectType)
is_graphql_objecttype = isinstance(type_, GraphQLObjectType)
assert is_graphene_objecttype or is_graphql_objecttype, (
"Type {} is not a valid ObjectType."
).format(_type)
).format(type_)


class Schema(GraphQLSchema):
Expand Down Expand Up @@ -72,26 +72,26 @@ def __getattr__(self, type_name):

Example: using schema.Query for accessing the "Query" type in the Schema
'''
_type = super(Schema, self).get_type(type_name)
if _type is None:
type_ = super(Schema, self).get_type(type_name)
if type_ is None:
raise AttributeError(
'Type "{}" not found in the Schema'.format(type_name))
if isinstance(_type, GrapheneGraphQLType):
return _type.graphene_type
return _type

def get_graphql_type(self, _type):
if not _type:
return _type
if is_type(_type):
return _type
if is_graphene_type(_type):
graphql_type = self.get_type(_type._meta.name)
if isinstance(type_, GrapheneGraphQLType):
return type_.graphene_type
return type_

def get_graphql_type(self, type_):
if not type_:
return type_
if is_type(type_):
return type_
if is_graphene_type(type_):
graphql_type = self.get_type(type_._meta.name)
assert graphql_type, "Type {} not found in this schema.".format(
_type._meta.name)
assert graphql_type.graphene_type == _type
type_._meta.name)
assert graphql_type.graphene_type == type_
return graphql_type
raise Exception("{} is not a valid GraphQL type.".format(_type))
raise Exception("{} is not a valid GraphQL type.".format(type_))

def execute(self, *args, **kwargs):
return graphql(self, *args, **kwargs)
Expand All @@ -105,8 +105,8 @@ def introspect(self):
def __str__(self):
return print_schema(self)

def lazy(self, _type):
return lambda: self.get_type(_type)
def lazy(self, type_):
return lambda: self.get_type(type_)

def build_typemap(self):
initial_types = [
Expand Down
Loading