From b377eb6230ce2ddfa3226ce433dae92c657d364c Mon Sep 17 00:00:00 2001 From: Syrus Akbary Date: Sun, 25 Oct 2015 22:34:37 -0700 Subject: [PATCH] Fixed Python3 errors --- graphene/__init__.py | 2 +- graphene/core/types.py | 14 ++++++++++---- tox.ini | 2 +- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/graphene/__init__.py b/graphene/__init__.py index ad3b3b10..9d29d8b2 100644 --- a/graphene/__init__.py +++ b/graphene/__init__.py @@ -6,7 +6,7 @@ from graphql.core.type import ( GraphQLID as ID ) -from graphene import signals +# from graphene import signals from graphene.core.schema import ( Schema diff --git a/graphene/core/types.py b/graphene/core/types.py index 34e17c0d..984932b8 100644 --- a/graphene/core/types.py +++ b/graphene/core/types.py @@ -53,16 +53,22 @@ class ObjectTypeMeta(type): assert not (new_class._meta.interface and new_class._meta.mutation) + input_class = None + if new_class._meta.mutation: + input_class = attrs.pop('Input', None) + # Add all attributes to the class. for obj_name, obj in attrs.items(): new_class.add_to_class(obj_name, obj) if new_class._meta.mutation: assert hasattr(new_class, 'mutate'), "All mutations must implement mutate method" - Input = getattr(new_class, 'Input', None) - if Input: - input_type = type('{}Input'.format(new_class._meta.type_name), (Input, ObjectType), Input.__dict__) - setattr(new_class, 'input_type', input_type) + + if input_class: + items = dict(input_class.__dict__) + items.pop('__dict__', None) + input_type = type('{}Input'.format(new_class._meta.type_name), (ObjectType, ), items) + new_class.add_to_class('input_type', input_type) new_class.add_extra_fields() diff --git a/tox.ini b/tox.ini index 6616be87..eebc612c 100644 --- a/tox.ini +++ b/tox.ini @@ -14,7 +14,7 @@ deps= setenv = PYTHONPATH = .:{envdir} commands= - py.test + py.test tests/ [pytest] DJANGO_SETTINGS_MODULE = tests.django_settings