mirror of
https://github.com/graphql-python/graphene.git
synced 2025-02-24 07:30:48 +03:00
Fixed lint issues and pypy install
This commit is contained in:
parent
48507b9a0f
commit
4775755e48
|
@ -4,7 +4,6 @@ python:
|
||||||
- 2.7
|
- 2.7
|
||||||
- 3.4
|
- 3.4
|
||||||
- 3.5
|
- 3.5
|
||||||
- pypy
|
|
||||||
before_install:
|
before_install:
|
||||||
- |
|
- |
|
||||||
if [ "$TRAVIS_PYTHON_VERSION" = "pypy" ]; then
|
if [ "$TRAVIS_PYTHON_VERSION" = "pypy" ]; then
|
||||||
|
|
|
@ -23,7 +23,8 @@ class ClientIDMutationMeta(ObjectTypeMeta):
|
||||||
base_name = re.sub('Payload$', '', name)
|
base_name = re.sub('Payload$', '', name)
|
||||||
if 'client_mutation_id' not in attrs:
|
if 'client_mutation_id' not in attrs:
|
||||||
attrs['client_mutation_id'] = String(name='clientMutationId')
|
attrs['client_mutation_id'] = String(name='clientMutationId')
|
||||||
cls = ObjectTypeMeta.__new__(cls, '{}Payload'.format(base_name), bases, attrs)
|
cls = ObjectTypeMeta.__new__(
|
||||||
|
cls, '{}Payload'.format(base_name), bases, attrs)
|
||||||
mutate_and_get_payload = getattr(cls, 'mutate_and_get_payload', None)
|
mutate_and_get_payload = getattr(cls, 'mutate_and_get_payload', None)
|
||||||
if cls.mutate and cls.mutate.__func__ == ClientIDMutation.mutate.__func__:
|
if cls.mutate and cls.mutate.__func__ == ClientIDMutation.mutate.__func__:
|
||||||
assert mutate_and_get_payload, (
|
assert mutate_and_get_payload, (
|
||||||
|
@ -39,8 +40,10 @@ class ClientIDMutationMeta(ObjectTypeMeta):
|
||||||
else:
|
else:
|
||||||
bases += (input_class, )
|
bases += (input_class, )
|
||||||
input_attrs['client_mutation_id'] = String(name='clientMutationId')
|
input_attrs['client_mutation_id'] = String(name='clientMutationId')
|
||||||
cls.Input = type('{}Input'.format(base_name), bases + (InputObjectType,), input_attrs)
|
cls.Input = type('{}Input'.format(base_name), bases +
|
||||||
cls.Field = partial(Field, cls, resolver=cls.mutate, input=Argument(cls.Input, required=True))
|
(InputObjectType,), input_attrs)
|
||||||
|
cls.Field = partial(Field, cls, resolver=cls.mutate,
|
||||||
|
input=Argument(cls.Input, required=True))
|
||||||
return cls
|
return cls
|
||||||
|
|
||||||
|
|
||||||
|
@ -53,7 +56,7 @@ class ClientIDMutation(six.with_metaclass(ClientIDMutationMeta, ObjectType)):
|
||||||
def on_resolve(payload):
|
def on_resolve(payload):
|
||||||
try:
|
try:
|
||||||
payload.client_mutation_id = input.get('clientMutationId')
|
payload.client_mutation_id = input.get('clientMutationId')
|
||||||
except:
|
except Exception:
|
||||||
raise Exception((
|
raise Exception((
|
||||||
'Cannot set client_mutation_id in the payload object {}'
|
'Cannot set client_mutation_id in the payload object {}'
|
||||||
).format(repr(payload)))
|
).format(repr(payload)))
|
||||||
|
|
|
@ -55,7 +55,8 @@ class NodeMeta(InterfaceMeta):
|
||||||
|
|
||||||
def __new__(cls, name, bases, attrs):
|
def __new__(cls, name, bases, attrs):
|
||||||
cls = InterfaceMeta.__new__(cls, name, bases, attrs)
|
cls = InterfaceMeta.__new__(cls, name, bases, attrs)
|
||||||
cls._meta.fields['id'] = GlobalID(cls, description='The ID of the object.')
|
cls._meta.fields['id'] = GlobalID(
|
||||||
|
cls, description='The ID of the object.')
|
||||||
return cls
|
return cls
|
||||||
|
|
||||||
|
|
||||||
|
@ -68,7 +69,8 @@ class NodeField(Field):
|
||||||
self.field_type = type
|
self.field_type = type
|
||||||
|
|
||||||
super(NodeField, self).__init__(
|
super(NodeField, self).__init__(
|
||||||
# If we don's specify a type, the field type will be the node interface
|
# If we don's specify a type, the field type will be the node
|
||||||
|
# interface
|
||||||
type or node,
|
type or node,
|
||||||
description='The ID of the object',
|
description='The ID of the object',
|
||||||
id=ID(required=True)
|
id=ID(required=True)
|
||||||
|
@ -94,7 +96,7 @@ class Node(six.with_metaclass(NodeMeta, Interface)):
|
||||||
try:
|
try:
|
||||||
_type, _id = cls.from_global_id(global_id)
|
_type, _id = cls.from_global_id(global_id)
|
||||||
graphene_type = info.schema.get_type(_type).graphene_type
|
graphene_type = info.schema.get_type(_type).graphene_type
|
||||||
except:
|
except Exception:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
if only_type:
|
if only_type:
|
||||||
|
|
|
@ -8,7 +8,7 @@ from .scalars import Scalar
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import iso8601
|
import iso8601
|
||||||
except:
|
except ImportError:
|
||||||
raise ImportError(
|
raise ImportError(
|
||||||
"iso8601 package is required for DateTime Scalar.\n"
|
"iso8601 package is required for DateTime Scalar.\n"
|
||||||
"You can install it using: pip install iso8601."
|
"You can install it using: pip install iso8601."
|
||||||
|
|
Loading…
Reference in New Issue
Block a user