mirror of
https://github.com/graphql-python/graphene.git
synced 2025-04-25 12:03:41 +03:00
Improved Python3 compat
This commit is contained in:
parent
145183d0ae
commit
ccfed3df3f
|
@ -15,7 +15,6 @@ except ImportError:
|
||||||
from ..utils.enum import Enum as PyEnum
|
from ..utils.enum import Enum as PyEnum
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class GrapheneEnumType(GrapheneGraphQLType, GraphQLEnumType):
|
class GrapheneEnumType(GrapheneGraphQLType, GraphQLEnumType):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -61,6 +60,9 @@ class EnumTypeMeta(type):
|
||||||
|
|
||||||
return cls
|
return cls
|
||||||
|
|
||||||
|
def __prepare__(name, bases, **kwargs):
|
||||||
|
return OrderedDict()
|
||||||
|
|
||||||
def __call__(cls, *args, **kwargs):
|
def __call__(cls, *args, **kwargs):
|
||||||
if cls is Enum:
|
if cls is Enum:
|
||||||
return cls.from_enum(PyEnum(*args, **kwargs))
|
return cls.from_enum(PyEnum(*args, **kwargs))
|
||||||
|
|
|
@ -95,7 +95,7 @@ class Field(AbstractField, GraphQLField, OrderedType):
|
||||||
# break
|
# break
|
||||||
|
|
||||||
if resolver:
|
if resolver:
|
||||||
resolver = resolver.__func__
|
resolver = getattr(resolver, '__func__', resolver)
|
||||||
else:
|
else:
|
||||||
resolver = self.default_resolver
|
resolver = self.default_resolver
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
from graphql.type import GraphQLEnumType, GraphQLEnumValue
|
from graphql.type import GraphQLEnumType, GraphQLEnumValue
|
||||||
|
|
||||||
from ...utils.enum import Enum as PyEnum
|
|
||||||
from ..argument import Argument
|
from ..argument import Argument
|
||||||
from ..enum import Enum
|
from ..enum import Enum, PyEnum
|
||||||
from ..field import Field
|
from ..field import Field
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -8,13 +8,13 @@ from ..get_fields import get_fields_from_attrs, get_fields_from_types
|
||||||
|
|
||||||
|
|
||||||
def test_get_fields_from_attrs():
|
def test_get_fields_from_attrs():
|
||||||
attrs = {
|
attrs = OrderedDict((
|
||||||
'field_string': Field(String),
|
('field_string', Field(String)),
|
||||||
'string': String(),
|
('string', String()),
|
||||||
'other': None,
|
('other', None),
|
||||||
'argument': Argument(String),
|
('argument', Argument(String)),
|
||||||
'graphql_field': GraphQLField(GraphQLString)
|
('graphql_field', GraphQLField(GraphQLString)),
|
||||||
}
|
))
|
||||||
extracted_fields = OrderedDict(get_fields_from_attrs(ObjectType, attrs))
|
extracted_fields = OrderedDict(get_fields_from_attrs(ObjectType, attrs))
|
||||||
assert [f for f in extracted_fields.keys()] == ['field_string', 'string']
|
assert [f for f in extracted_fields.keys()] == ['field_string', 'string']
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user