mirror of
https://github.com/graphql-python/graphene.git
synced 2025-06-07 07:03:05 +03:00
Removed unnecessary files
This commit is contained in:
parent
d2f1024d81
commit
b892eee0ae
|
@ -1,56 +1,42 @@
|
||||||
# THIS IS THE OLD IMPLEMENTATION, for Graphene 1.0
|
# https://github.com/graphql-python/graphene/issues/425
|
||||||
# Keep here as reference for upgrade.
|
# Adapted for Graphene 2.0
|
||||||
|
|
||||||
# # https://github.com/graphql-python/graphene/issues/425
|
from graphene.types.objecttype import ObjectType, ObjectTypeOptions
|
||||||
# import six
|
|
||||||
|
|
||||||
# from graphene.utils.is_base_type import is_base_type
|
|
||||||
|
|
||||||
# from graphene.types.objecttype import ObjectTypeMeta, ObjectType
|
|
||||||
# from graphene.types.options import Options
|
|
||||||
|
|
||||||
# class SpecialObjectTypeMeta(ObjectTypeMeta):
|
|
||||||
|
|
||||||
# @staticmethod
|
|
||||||
# def __new__(cls, name, bases, attrs):
|
|
||||||
# # Also ensure initialization is only performed for subclasses of
|
|
||||||
# # DjangoObjectType
|
|
||||||
# if not is_base_type(bases, SpecialObjectTypeMeta):
|
|
||||||
# return type.__new__(cls, name, bases, attrs)
|
|
||||||
|
|
||||||
# options = Options(
|
|
||||||
# attrs.pop('Meta', None),
|
|
||||||
# other_attr='default',
|
|
||||||
# )
|
|
||||||
|
|
||||||
# cls = ObjectTypeMeta.__new__(cls, name, bases, dict(attrs, _meta=options))
|
|
||||||
# assert cls._meta is options
|
|
||||||
# return cls
|
|
||||||
|
|
||||||
|
|
||||||
# class SpecialObjectType(six.with_metaclass(SpecialObjectTypeMeta, ObjectType)):
|
class SpecialOptions(ObjectTypeOptions):
|
||||||
# pass
|
other_attr = None
|
||||||
|
|
||||||
|
|
||||||
# def test_special_objecttype_could_be_subclassed():
|
class SpecialObjectType(ObjectType):
|
||||||
# class MyType(SpecialObjectType):
|
|
||||||
# class Meta:
|
|
||||||
# other_attr = 'yeah!'
|
|
||||||
|
|
||||||
# assert MyType._meta.other_attr == 'yeah!'
|
@classmethod
|
||||||
|
def __init_subclass_with_meta__(cls, other_attr='default', **options):
|
||||||
|
_meta = SpecialOptions(cls)
|
||||||
|
_meta.other_attr = other_attr
|
||||||
|
super(SpecialObjectType, cls).__init_subclass_with_meta__(_meta=_meta, **options)
|
||||||
|
|
||||||
|
|
||||||
# def test_special_objecttype_could_be_subclassed_default():
|
def test_special_objecttype_could_be_subclassed():
|
||||||
# class MyType(SpecialObjectType):
|
class MyType(SpecialObjectType):
|
||||||
# pass
|
|
||||||
|
|
||||||
# assert MyType._meta.other_attr == 'default'
|
class Meta:
|
||||||
|
other_attr = 'yeah!'
|
||||||
|
|
||||||
|
assert MyType._meta.other_attr == 'yeah!'
|
||||||
|
|
||||||
|
|
||||||
# def test_special_objecttype_inherit_meta_options():
|
def test_special_objecttype_could_be_subclassed_default():
|
||||||
# class MyType(SpecialObjectType):
|
class MyType(SpecialObjectType):
|
||||||
# pass
|
pass
|
||||||
|
|
||||||
# assert MyType._meta.name == 'MyType'
|
assert MyType._meta.other_attr == 'default'
|
||||||
# assert MyType._meta.default_resolver == None
|
|
||||||
# assert MyType._meta.interfaces == ()
|
|
||||||
|
def test_special_objecttype_inherit_meta_options():
|
||||||
|
class MyType(SpecialObjectType):
|
||||||
|
pass
|
||||||
|
|
||||||
|
assert MyType._meta.name == 'MyType'
|
||||||
|
assert MyType._meta.default_resolver is None
|
||||||
|
assert MyType._meta.interfaces == ()
|
||||||
|
|
|
@ -1,42 +0,0 @@
|
||||||
# https://github.com/graphql-python/graphene/issues/425
|
|
||||||
# Adapted for Graphene 2.0
|
|
||||||
|
|
||||||
from graphene.types.objecttype import ObjectType, ObjectTypeOptions
|
|
||||||
|
|
||||||
|
|
||||||
class SpecialOptions(ObjectTypeOptions):
|
|
||||||
other_attr = None
|
|
||||||
|
|
||||||
|
|
||||||
class SpecialObjectType(ObjectType):
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def __init_subclass_with_meta__(cls, other_attr='default', **options):
|
|
||||||
_meta = SpecialOptions(cls)
|
|
||||||
_meta.other_attr = other_attr
|
|
||||||
super(SpecialObjectType, cls).__init_subclass_with_meta__(_meta=_meta, **options)
|
|
||||||
|
|
||||||
|
|
||||||
def test_special_objecttype_could_be_subclassed():
|
|
||||||
class MyType(SpecialObjectType):
|
|
||||||
|
|
||||||
class Meta:
|
|
||||||
other_attr = 'yeah!'
|
|
||||||
|
|
||||||
assert MyType._meta.other_attr == 'yeah!'
|
|
||||||
|
|
||||||
|
|
||||||
def test_special_objecttype_could_be_subclassed_default():
|
|
||||||
class MyType(SpecialObjectType):
|
|
||||||
pass
|
|
||||||
|
|
||||||
assert MyType._meta.other_attr == 'default'
|
|
||||||
|
|
||||||
|
|
||||||
def test_special_objecttype_inherit_meta_options():
|
|
||||||
class MyType(SpecialObjectType):
|
|
||||||
pass
|
|
||||||
|
|
||||||
assert MyType._meta.name == 'MyType'
|
|
||||||
assert MyType._meta.default_resolver is None
|
|
||||||
assert MyType._meta.interfaces == ()
|
|
|
@ -1,3 +0,0 @@
|
||||||
|
|
||||||
def is_base_type(bases, _type):
|
|
||||||
return any(b for b in bases if isinstance(b, _type))
|
|
Loading…
Reference in New Issue
Block a user