diff --git a/graphene/new_types/abstracttype.py b/graphene/new_types/abstracttype.py index 3de3b290..927c5fae 100644 --- a/graphene/new_types/abstracttype.py +++ b/graphene/new_types/abstracttype.py @@ -10,7 +10,7 @@ class AbstractTypeMeta(type): def __new__(cls, name, bases, attrs): # Also ensure initialization is only performed for subclasses of - # ObjectType + # AbstractType if not is_base_type(bases, AbstractTypeMeta): return type.__new__(cls, name, bases, attrs) @@ -20,7 +20,7 @@ class AbstractTypeMeta(type): return type.__new__(cls, name, bases, attrs) attrs = merge_fields_in_attrs(bases, attrs) - fields = get_fields_in_type(cls, attrs) + fields = get_fields_in_type(AbstractType, attrs) yank_fields_from_attrs(attrs, fields) options = attrs.get('_meta', Options()) diff --git a/graphene/new_types/interface.py b/graphene/new_types/interface.py index 2c46f814..8058c82d 100644 --- a/graphene/new_types/interface.py +++ b/graphene/new_types/interface.py @@ -23,7 +23,7 @@ class InterfaceMeta(AbstractTypeMeta): ) attrs = merge_fields_in_attrs(bases, attrs) - options.fields = get_fields_in_type(cls, attrs) + options.fields = get_fields_in_type(Interface, attrs) yank_fields_from_attrs(attrs, options.fields) return type.__new__(cls, name, bases, dict(attrs, _meta=options)) @@ -35,6 +35,6 @@ class Interface(six.with_metaclass(InterfaceMeta)): def __init__(self, *args, **kwargs): raise Exception("An interface cannot be intitialized") - @classmethod - def implements(cls, objecttype): - pass + # @classmethod + # def implements(cls, objecttype): + # pass diff --git a/graphene/new_types/objecttype.py b/graphene/new_types/objecttype.py index fa5e6303..92c38e42 100644 --- a/graphene/new_types/objecttype.py +++ b/graphene/new_types/objecttype.py @@ -23,7 +23,7 @@ class ObjectTypeMeta(AbstractTypeMeta): ) attrs = merge_fields_in_attrs(bases, attrs) - options.fields = get_fields_in_type(cls, attrs) + options.fields = get_fields_in_type(ObjectType, attrs) yank_fields_from_attrs(attrs, options.fields) return type.__new__(cls, name, bases, dict(attrs, _meta=options)) diff --git a/graphene/new_types/tests/test_abstracttype.py b/graphene/new_types/tests/test_abstracttype.py index d6e9069c..ab5cb43e 100644 --- a/graphene/new_types/tests/test_abstracttype.py +++ b/graphene/new_types/tests/test_abstracttype.py @@ -40,61 +40,3 @@ def test_generate_abstracttype_inheritance(): assert MyAbstractType2._meta.fields.keys() == ['field1', 'field2'] assert not hasattr(MyAbstractType1, 'field1') assert not hasattr(MyAbstractType2, 'field2') - -# def test_ordered_fields_in_objecttype(): -# class MyObjectType(ObjectType): -# b = Field(MyType) -# a = Field(MyType) -# field = MyScalar() -# asa = Field(MyType) - -# assert list(MyObjectType._meta.fields.keys()) == ['b', 'a', 'field', 'asa'] - - -# def test_generate_objecttype_unmountedtype(): -# class MyObjectType(ObjectType): -# field = MyScalar(MyType) - -# assert 'field' in MyObjectType._meta.fields -# assert isinstance(MyObjectType._meta.fields['field'], Field) - - -# def test_parent_container_get_fields(): -# assert list(Container._meta.fields.keys()) == ['field1', 'field2'] - - -# def test_objecttype_as_container_only_args(): -# container = Container("1", "2") -# assert container.field1 == "1" -# assert container.field2 == "2" - - -# def test_objecttype_as_container_args_kwargs(): -# container = Container("1", field2="2") -# assert container.field1 == "1" -# assert container.field2 == "2" - - -# def test_objecttype_as_container_few_kwargs(): -# container = Container(field2="2") -# assert container.field2 == "2" - - -# def test_objecttype_as_container_all_kwargs(): -# container = Container(field1="1", field2="2") -# assert container.field1 == "1" -# assert container.field2 == "2" - - -# def test_objecttype_as_container_extra_args(): -# with pytest.raises(IndexError) as excinfo: -# Container("1", "2", "3") - -# assert "Number of args exceeds number of fields" == str(excinfo.value) - - -# def test_objecttype_as_container_invalid_kwargs(): -# with pytest.raises(TypeError) as excinfo: -# Container(unexisting_field="3") - -# assert "'unexisting_field' is an invalid keyword argument for Container" == str(excinfo.value) diff --git a/graphene/new_types/utils.py b/graphene/new_types/utils.py index 6ffbb8d0..c5443e3a 100644 --- a/graphene/new_types/utils.py +++ b/graphene/new_types/utils.py @@ -25,14 +25,14 @@ def unmounted_field_in_type(attname, unmounted_field, type): InputObjectType -> InputField ''' # from ..types.inputobjecttype import InputObjectType - from ..new_types.objecttype import ObjectTypeMeta - from ..new_types.interface import InterfaceMeta - from ..new_types.abstracttype import AbstractTypeMeta + from ..new_types.objecttype import ObjectType + from ..new_types.interface import Interface + from ..new_types.abstracttype import AbstractType - if issubclass(type, (ObjectTypeMeta, InterfaceMeta)): + if issubclass(type, (ObjectType, Interface)): return unmounted_field.as_field() - elif issubclass(type, (AbstractTypeMeta)): + elif issubclass(type, (AbstractType)): return unmounted_field # elif issubclass(type, (InputObjectType)): # return unmounted_field.as_inputfield()