From eec4c52c330d1d28f78975811f93ba0f54c85a00 Mon Sep 17 00:00:00 2001 From: Syrus Akbary Date: Fri, 10 Jun 2016 22:40:22 -0700 Subject: [PATCH] Renamed from TypeProxy to UnmountedType --- graphene/types/argument.py | 4 ++-- graphene/types/definitions.py | 6 ------ graphene/types/enum.py | 4 ++-- graphene/types/inputobjecttype.py | 4 ++-- graphene/types/scalars.py | 4 ++-- graphene/types/structures.py | 4 ++-- graphene/types/{proxy.py => unmountedtype.py} | 4 ++-- graphene/utils/extract_fields.py | 4 ++-- 8 files changed, 14 insertions(+), 20 deletions(-) rename graphene/types/{proxy.py => unmountedtype.py} (95%) diff --git a/graphene/types/argument.py b/graphene/types/argument.py index 781232f2..52a96c9e 100644 --- a/graphene/types/argument.py +++ b/graphene/types/argument.py @@ -41,13 +41,13 @@ class Argument(GraphQLArgument, OrderedType): def to_arguments(*args, **extra): - from .proxy import TypeProxy + from .unmountedtype import UnmountedType args = list(filter(None, args)) + [extra] arguments = [] iter_arguments = chain(*[arg.items() for arg in args]) arguments_names = set() for default_name, arg in iter_arguments: - if isinstance(arg, TypeProxy): + if isinstance(arg, UnmountedType): arg = arg.as_argument() if not isinstance(arg, GraphQLArgument): diff --git a/graphene/types/definitions.py b/graphene/types/definitions.py index 6da3fa75..db3fb389 100644 --- a/graphene/types/definitions.py +++ b/graphene/types/definitions.py @@ -27,12 +27,6 @@ class ClassTypeMeta(type): meta = attr_meta new_class._meta = new_class.get_options(meta) - new_class._meta.parent = new_class - new_class._meta.validate_attrs() - - if new_class._meta.name: - assert_valid_name(new_class._meta.name) - return mcs.construct(new_class, bases, attrs) def get_options(cls, meta): diff --git a/graphene/types/enum.py b/graphene/types/enum.py index 586dcaaf..9eff8c1a 100644 --- a/graphene/types/enum.py +++ b/graphene/types/enum.py @@ -7,7 +7,7 @@ try: except ImportError: from ..utils.enum import Enum as PyEnum -from .proxy import TypeProxy +from .unmountedtype import UnmountedType class GrapheneEnumType(GrapheneGraphQLType, GraphQLEnumType): @@ -66,6 +66,6 @@ class EnumTypeMeta(ClassTypeMeta): return type(Meta.enum.__name__, (Enum,), {'Meta': Meta}) -class Enum(six.with_metaclass(EnumTypeMeta, TypeProxy)): +class Enum(six.with_metaclass(EnumTypeMeta, UnmountedType)): class Meta: abstract = True diff --git a/graphene/types/inputobjecttype.py b/graphene/types/inputobjecttype.py index 8651df37..57b65b9d 100644 --- a/graphene/types/inputobjecttype.py +++ b/graphene/types/inputobjecttype.py @@ -3,7 +3,7 @@ import six from graphql import GraphQLInputObjectType from .definitions import FieldsMeta, ClassTypeMeta, GrapheneGraphQLType -from .proxy import TypeProxy +from .unmountedtype import UnmountedType class GrapheneInputObjectType(GrapheneGraphQLType, GraphQLInputObjectType): @@ -36,6 +36,6 @@ class InputObjectTypeMeta(FieldsMeta, ClassTypeMeta): return super(InputObjectTypeMeta, cls).construct(bases, attrs) -class InputObjectType(six.with_metaclass(InputObjectTypeMeta, TypeProxy)): +class InputObjectType(six.with_metaclass(InputObjectTypeMeta, UnmountedType)): class Meta: abstract = True diff --git a/graphene/types/scalars.py b/graphene/types/scalars.py index 40b3e719..cf4a115e 100644 --- a/graphene/types/scalars.py +++ b/graphene/types/scalars.py @@ -2,7 +2,7 @@ import six from graphql import GraphQLScalarType, GraphQLString, GraphQLInt, GraphQLFloat, GraphQLBoolean, GraphQLID from .definitions import ClassTypeMeta, GrapheneGraphQLType -from .proxy import TypeProxy +from .unmountedtype import UnmountedType class GrapheneScalarType(GrapheneGraphQLType, GraphQLScalarType): @@ -36,7 +36,7 @@ class ScalarTypeMeta(ClassTypeMeta): return constructed -class Scalar(six.with_metaclass(ScalarTypeMeta, TypeProxy)): +class Scalar(six.with_metaclass(ScalarTypeMeta, UnmountedType)): class Meta: abstract = True diff --git a/graphene/types/structures.py b/graphene/types/structures.py index 409dcda0..d2ad1716 100644 --- a/graphene/types/structures.py +++ b/graphene/types/structures.py @@ -2,10 +2,10 @@ import inspect from graphql import GraphQLList, GraphQLNonNull -from .proxy import TypeProxy +from .unmountedtype import UnmountedType -class Structure(TypeProxy): +class Structure(UnmountedType): def __init__(self, of_type, *args, **kwargs): super(Structure, self).__init__(*args, **kwargs) self.of_type = of_type diff --git a/graphene/types/proxy.py b/graphene/types/unmountedtype.py similarity index 95% rename from graphene/types/proxy.py rename to graphene/types/unmountedtype.py index 44b55897..a7514e16 100644 --- a/graphene/types/proxy.py +++ b/graphene/types/unmountedtype.py @@ -5,7 +5,7 @@ from ..utils.orderedtype import OrderedType # UnmountedType ? -class TypeProxy(OrderedType): +class UnmountedType(OrderedType): ''' This class acts a proxy for a Graphene Type, so it can be mounted as Field, InputField or Argument. @@ -24,7 +24,7 @@ class TypeProxy(OrderedType): def __init__(self, *args, **kwargs): self.args = args self.kwargs = kwargs - super(TypeProxy, self).__init__() + super(UnmountedType, self).__init__() def get_type(self): return self._meta.graphql_type diff --git a/graphene/utils/extract_fields.py b/graphene/utils/extract_fields.py index cb23526f..963ec482 100644 --- a/graphene/utils/extract_fields.py +++ b/graphene/utils/extract_fields.py @@ -2,7 +2,7 @@ import copy from .get_graphql_type import get_graphql_type from ..types.field import Field, InputField -from ..types.proxy import TypeProxy +from ..types.unmountedtype import UnmountedType def extract_fields(cls, attrs): @@ -10,7 +10,7 @@ def extract_fields(cls, attrs): _fields = list() for attname, value in list(attrs.items()): is_field = isinstance(value, (Field, InputField)) - is_field_proxy = isinstance(value, TypeProxy) + is_field_proxy = isinstance(value, UnmountedType) if not (is_field or is_field_proxy): continue field = value.as_mounted(cls) if is_field_proxy else copy.copy(value)