mirror of
https://github.com/graphql-python/graphene.git
synced 2024-11-14 21:56:54 +03:00
Remove six dependency (#986)
* No one is using func_name * Remove six simple usages * Remove six requirement * Remove `six.with_metaclass` calls
This commit is contained in:
parent
6e2bb3bc30
commit
af6396b63b
|
@ -1,21 +1,8 @@
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
|
|
||||||
import six
|
|
||||||
|
|
||||||
from graphql.pyutils.compat import Enum
|
from graphql.pyutils.compat import Enum
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from inspect import signature
|
from inspect import signature
|
||||||
except ImportError:
|
except ImportError:
|
||||||
from .signature import signature
|
from .signature import signature
|
||||||
|
|
||||||
if six.PY2:
|
|
||||||
|
|
||||||
def func_name(func):
|
|
||||||
return func.func_name
|
|
||||||
|
|
||||||
|
|
||||||
else:
|
|
||||||
|
|
||||||
def func_name(func):
|
|
||||||
return func.__name__
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
from promise import Promise, is_thenable
|
from promise import Promise, is_thenable
|
||||||
import six
|
|
||||||
from graphql.error import format_error as format_graphql_error
|
from graphql.error import format_error as format_graphql_error
|
||||||
from graphql.error import GraphQLError
|
from graphql.error import GraphQLError
|
||||||
|
|
||||||
|
@ -10,7 +9,7 @@ def default_format_error(error):
|
||||||
if isinstance(error, GraphQLError):
|
if isinstance(error, GraphQLError):
|
||||||
return format_graphql_error(error)
|
return format_graphql_error(error)
|
||||||
|
|
||||||
return {"message": six.text_type(error)}
|
return {"message": str(error)}
|
||||||
|
|
||||||
|
|
||||||
def format_execution_result(execution_result, format_error):
|
def format_execution_result(execution_result, format_error):
|
||||||
|
|
|
@ -4,7 +4,6 @@ import datetime
|
||||||
|
|
||||||
from aniso8601 import parse_date, parse_datetime, parse_time
|
from aniso8601 import parse_date, parse_datetime, parse_time
|
||||||
from graphql.language import ast
|
from graphql.language import ast
|
||||||
from six import string_types
|
|
||||||
|
|
||||||
from .scalars import Scalar
|
from .scalars import Scalar
|
||||||
|
|
||||||
|
@ -35,7 +34,7 @@ class Date(Scalar):
|
||||||
try:
|
try:
|
||||||
if isinstance(value, datetime.date):
|
if isinstance(value, datetime.date):
|
||||||
return value
|
return value
|
||||||
elif isinstance(value, string_types):
|
elif isinstance(value, str):
|
||||||
return parse_date(value)
|
return parse_date(value)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
return None
|
return None
|
||||||
|
@ -65,7 +64,7 @@ class DateTime(Scalar):
|
||||||
try:
|
try:
|
||||||
if isinstance(value, datetime.datetime):
|
if isinstance(value, datetime.datetime):
|
||||||
return value
|
return value
|
||||||
elif isinstance(value, string_types):
|
elif isinstance(value, str):
|
||||||
return parse_datetime(value)
|
return parse_datetime(value)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
return None
|
return None
|
||||||
|
@ -95,7 +94,7 @@ class Time(Scalar):
|
||||||
try:
|
try:
|
||||||
if isinstance(value, datetime.time):
|
if isinstance(value, datetime.time):
|
||||||
return value
|
return value
|
||||||
elif isinstance(value, string_types):
|
elif isinstance(value, str):
|
||||||
return parse_time(value)
|
return parse_time(value)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
return None
|
return None
|
||||||
|
|
|
@ -1,7 +1,4 @@
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
|
|
||||||
import six
|
|
||||||
|
|
||||||
from graphene.utils.subclass_with_meta import SubclassWithMeta_Meta
|
from graphene.utils.subclass_with_meta import SubclassWithMeta_Meta
|
||||||
|
|
||||||
from ..pyutils.compat import Enum as PyEnum
|
from ..pyutils.compat import Enum as PyEnum
|
||||||
|
@ -66,7 +63,7 @@ class EnumMeta(SubclassWithMeta_Meta):
|
||||||
return type(meta_class.enum.__name__, (Enum,), {"Meta": meta_class})
|
return type(meta_class.enum.__name__, (Enum,), {"Meta": meta_class})
|
||||||
|
|
||||||
|
|
||||||
class Enum(six.with_metaclass(EnumMeta, UnmountedType, BaseType)):
|
class Enum(UnmountedType, BaseType, metaclass=EnumMeta):
|
||||||
@classmethod
|
@classmethod
|
||||||
def __init_subclass_with_meta__(cls, enum=None, _meta=None, **options):
|
def __init_subclass_with_meta__(cls, enum=None, _meta=None, **options):
|
||||||
if not _meta:
|
if not _meta:
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import six
|
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from graphql.language.ast import BooleanValue, FloatValue, IntValue, StringValue
|
from graphql.language.ast import BooleanValue, FloatValue, IntValue, StringValue
|
||||||
|
@ -113,7 +112,7 @@ class String(Scalar):
|
||||||
def coerce_string(value):
|
def coerce_string(value):
|
||||||
if isinstance(value, bool):
|
if isinstance(value, bool):
|
||||||
return u"true" if value else u"false"
|
return u"true" if value else u"false"
|
||||||
return six.text_type(value)
|
return str(value)
|
||||||
|
|
||||||
serialize = coerce_string
|
serialize = coerce_string
|
||||||
parse_value = coerce_string
|
parse_value = coerce_string
|
||||||
|
|
|
@ -2,8 +2,6 @@ import inspect
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
from functools import partial
|
from functools import partial
|
||||||
|
|
||||||
from six import string_types
|
|
||||||
|
|
||||||
from ..utils.module_loading import import_string
|
from ..utils.module_loading import import_string
|
||||||
from .mountedtype import MountedType
|
from .mountedtype import MountedType
|
||||||
from .unmountedtype import UnmountedType
|
from .unmountedtype import UnmountedType
|
||||||
|
@ -39,7 +37,7 @@ def yank_fields_from_attrs(attrs, _as=None, sort=True):
|
||||||
|
|
||||||
|
|
||||||
def get_type(_type):
|
def get_type(_type):
|
||||||
if isinstance(_type, string_types):
|
if isinstance(_type, str):
|
||||||
return import_string(_type)
|
return import_string(_type)
|
||||||
if inspect.isfunction(_type) or isinstance(_type, partial):
|
if inspect.isfunction(_type) or isinstance(_type, partial):
|
||||||
return _type()
|
return _type()
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
import six
|
|
||||||
from uuid import UUID as _UUID
|
from uuid import UUID as _UUID
|
||||||
|
|
||||||
from graphql.language import ast
|
from graphql.language import ast
|
||||||
|
@ -12,7 +11,7 @@ class UUID(Scalar):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def serialize(uuid):
|
def serialize(uuid):
|
||||||
if isinstance(uuid, six.string_types):
|
if isinstance(uuid, str):
|
||||||
uuid = _UUID(uuid)
|
uuid = _UUID(uuid)
|
||||||
|
|
||||||
assert isinstance(uuid, _UUID), "Expected UUID instance, received {}".format(
|
assert isinstance(uuid, _UUID), "Expected UUID instance, received {}".format(
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
from inspect import isclass
|
from inspect import isclass
|
||||||
|
|
||||||
import six
|
|
||||||
|
|
||||||
from ..pyutils.init_subclass import InitSubclassMeta
|
from ..pyutils.init_subclass import InitSubclassMeta
|
||||||
from .props import props
|
from .props import props
|
||||||
|
|
||||||
|
@ -18,7 +16,7 @@ class SubclassWithMeta_Meta(InitSubclassMeta):
|
||||||
return "<{} meta={}>".format(cls.__name__, repr(cls._meta))
|
return "<{} meta={}>".format(cls.__name__, repr(cls._meta))
|
||||||
|
|
||||||
|
|
||||||
class SubclassWithMeta(six.with_metaclass(SubclassWithMeta_Meta)):
|
class SubclassWithMeta(metaclass=SubclassWithMeta_Meta):
|
||||||
"""This class improves __init_subclass__ to receive automatically the options from meta"""
|
"""This class improves __init_subclass__ to receive automatically the options from meta"""
|
||||||
|
|
||||||
# We will only have the metaclass in Python 2
|
# We will only have the metaclass in Python 2
|
||||||
|
|
1
setup.py
1
setup.py
|
@ -79,7 +79,6 @@ setup(
|
||||||
keywords="api graphql protocol rest relay graphene",
|
keywords="api graphql protocol rest relay graphene",
|
||||||
packages=find_packages(exclude=["tests", "tests.*", "examples"]),
|
packages=find_packages(exclude=["tests", "tests.*", "examples"]),
|
||||||
install_requires=[
|
install_requires=[
|
||||||
"six>=1.10.0,<2",
|
|
||||||
"graphql-core>=2.1,<3",
|
"graphql-core>=2.1,<3",
|
||||||
"graphql-relay>=0.4.5,<1",
|
"graphql-relay>=0.4.5,<1",
|
||||||
"aniso8601>=3,<=6.0.*",
|
"aniso8601>=3,<=6.0.*",
|
||||||
|
|
Loading…
Reference in New Issue
Block a user