From 31ea09ff30738e049e95c51e1a980abff5233c3e Mon Sep 17 00:00:00 2001 From: Syrus Akbary Date: Sat, 4 Jun 2016 19:10:18 -0700 Subject: [PATCH] Improved options --- graphene/types/enum.py | 5 ++--- graphene/types/inputobjecttype.py | 5 ++--- graphene/types/interface.py | 5 ++--- graphene/types/objecttype.py | 5 ++--- graphene/types/options.py | 2 +- graphene/types/scalars.py | 5 ++--- 6 files changed, 11 insertions(+), 16 deletions(-) diff --git a/graphene/types/enum.py b/graphene/types/enum.py index 0c1d79e8..4c7799ba 100644 --- a/graphene/types/enum.py +++ b/graphene/types/enum.py @@ -33,15 +33,14 @@ class GrapheneEnumType(GrapheneType, GraphQLEnumType): class EnumTypeMeta(ClassTypeMeta): def get_options(cls, meta): - options = cls.options_class( + return cls.options_class( meta, name=None, description=None, enum=None, graphql_type=None, + abstract=False ) - options.valid_attrs = ['graphql_type', 'name', 'description', 'enum', 'abstract'] - return options def construct_graphql_type(cls, bases): if not cls._meta.graphql_type and not cls._meta.abstract: diff --git a/graphene/types/inputobjecttype.py b/graphene/types/inputobjecttype.py index 734cf617..b319ce28 100644 --- a/graphene/types/inputobjecttype.py +++ b/graphene/types/inputobjecttype.py @@ -13,14 +13,13 @@ class GrapheneInputObjectType(GrapheneFieldsType, GraphQLInputObjectType): class InputObjectTypeMeta(ClassTypeMeta): def get_options(cls, meta): - options = cls.options_class( + return cls.options_class( meta, name=None, description=None, graphql_type=None, + abstract=False ) - options.valid_attrs = ['graphql_type', 'name', 'description', 'abstract'] - return options def construct_graphql_type(cls, bases): if not cls._meta.graphql_type and not cls._meta.abstract: diff --git a/graphene/types/interface.py b/graphene/types/interface.py index 9b2af576..491fa31f 100644 --- a/graphene/types/interface.py +++ b/graphene/types/interface.py @@ -11,14 +11,13 @@ class GrapheneInterfaceType(GrapheneFieldsType, GraphQLInterfaceType): class InterfaceTypeMeta(ClassTypeMeta): def get_options(cls, meta): - options = cls.options_class( + return cls.options_class( meta, name=None, description=None, graphql_type=None, + abstract=False ) - options.valid_attrs = ['graphql_type', 'name', 'description', 'abstract'] - return options def construct_graphql_type(cls, bases): if not cls._meta.graphql_type and not cls._meta.abstract: diff --git a/graphene/types/objecttype.py b/graphene/types/objecttype.py index c66a601e..efc7b669 100644 --- a/graphene/types/objecttype.py +++ b/graphene/types/objecttype.py @@ -41,15 +41,14 @@ class GrapheneObjectType(GrapheneFieldsType, GraphQLObjectType): class ObjectTypeMeta(ClassTypeMeta): def get_options(cls, meta): - options = cls.options_class( + return cls.options_class( meta, name=None, description=None, graphql_type=None, interfaces=[], + abstract=False ) - options.valid_attrs = ['graphql_type', 'name', 'description', 'interfaces', 'abstract'] - return options def construct_graphql_type(cls, bases): if not cls._meta.graphql_type and not cls._meta.abstract: diff --git a/graphene/types/options.py b/graphene/types/options.py index be179d71..59b30f8c 100644 --- a/graphene/types/options.py +++ b/graphene/types/options.py @@ -6,7 +6,7 @@ class Options(object): self.parent = None for name, value in defaults.items(): setattr(self, name, value) - self.valid_attrs = [] + self.valid_attrs = defaults.keys() def contribute_to_class(self, cls, name): cls._meta = self diff --git a/graphene/types/scalars.py b/graphene/types/scalars.py index 2d66d11c..5287eb05 100644 --- a/graphene/types/scalars.py +++ b/graphene/types/scalars.py @@ -50,14 +50,13 @@ class GrapheneScalarType(GrapheneType, GraphQLScalarType): class ScalarTypeMeta(ClassTypeMeta): def get_options(cls, meta): - options = cls.options_class( + return cls.options_class( meta, name=None, description=None, graphql_type=None, + abstract=False ) - options.valid_attrs = ['graphql_type', 'name', 'description', 'abstract'] - return options def construct_graphql_type(cls, bases): if not cls._meta.graphql_type and not cls._meta.abstract: