mirror of
https://github.com/graphql-python/graphene.git
synced 2025-07-18 03:52:24 +03:00
remove six
This commit is contained in:
parent
44e5bb9177
commit
fb499d189d
|
@ -1,2 +1,2 @@
|
||||||
[settings]
|
[settings]
|
||||||
known_third_party = aniso8601,graphql,graphql_relay,promise,pytest,pytz,pyutils,setuptools,six,snapshottest,sphinx_graphene_theme
|
known_third_party = aniso8601,graphql,graphql_relay,promise,pytest,pytz,pyutils,setuptools,snapshottest,sphinx_graphene_theme
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
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:
|
||||||
|
@ -9,13 +7,6 @@ try:
|
||||||
except ImportError:
|
except ImportError:
|
||||||
from .signature import signature
|
from .signature import signature
|
||||||
|
|
||||||
if six.PY2:
|
|
||||||
|
|
||||||
def func_name(func):
|
def func_name(func):
|
||||||
return func.func_name
|
return 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
|
||||||
|
|
||||||
|
@ -9,8 +8,7 @@ from graphene.types.schema import Schema
|
||||||
def default_format_error(error):
|
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": str(error)}
|
||||||
return {"message": six.text_type(error)}
|
|
||||||
|
|
||||||
|
|
||||||
def format_execution_result(execution_result, format_error):
|
def format_execution_result(execution_result, format_error):
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
from ..utils.subclass_with_meta import SubclassWithMeta
|
from ..utils.subclass_with_meta import SubclassWithMeta
|
||||||
from ..utils.trim_docstring import trim_docstring
|
from ..utils.trim_docstring import trim_docstring
|
||||||
import six
|
|
||||||
|
|
||||||
if six.PY3:
|
from typing import Type
|
||||||
from typing import Type
|
|
||||||
|
|
||||||
|
|
||||||
class BaseOptions(object):
|
class BaseOptions(object):
|
||||||
|
|
|
@ -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,5 @@
|
||||||
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 +64,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):
|
||||||
"""
|
"""
|
||||||
Enum type definition
|
Enum type definition
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
import six
|
|
||||||
from graphql.language.ast import BooleanValue, FloatValue, IntValue, StringValue
|
from graphql.language.ast import BooleanValue, FloatValue, IntValue, StringValue
|
||||||
|
|
||||||
from .base import BaseOptions, BaseType
|
from .base import BaseOptions, BaseType
|
||||||
from .unmountedtype import UnmountedType
|
from .unmountedtype import UnmountedType
|
||||||
|
|
||||||
if six.PY3:
|
from typing import Any
|
||||||
from typing import Any
|
|
||||||
|
|
||||||
|
|
||||||
class ScalarOptions(BaseOptions):
|
class ScalarOptions(BaseOptions):
|
||||||
|
@ -114,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
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
import six
|
|
||||||
|
|
||||||
from ..argument import Argument
|
from ..argument import Argument
|
||||||
from ..enum import Enum, PyEnum
|
from ..enum import Enum, PyEnum
|
||||||
from ..field import Field
|
from ..field import Field
|
||||||
|
@ -115,8 +113,6 @@ def test_enum_from_builtin_enum_accepts_lambda_description():
|
||||||
|
|
||||||
|
|
||||||
def test_enum_from_python3_enum_uses_enum_doc():
|
def test_enum_from_python3_enum_uses_enum_doc():
|
||||||
if not six.PY3:
|
|
||||||
return
|
|
||||||
|
|
||||||
from enum import Enum as PyEnum
|
from enum import Enum as PyEnum
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
@ -15,7 +14,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,11 +1,9 @@
|
||||||
import six
|
|
||||||
|
|
||||||
from ..pyutils.compat import func_name, signature
|
from ..pyutils.compat import func_name, signature
|
||||||
from .deprecated import warn_deprecation
|
from .deprecated import warn_deprecation
|
||||||
|
|
||||||
|
|
||||||
def annotate(_func=None, _trigger_warning=True, **annotations):
|
def annotate(_func=None, _trigger_warning=True, **annotations):
|
||||||
if not six.PY2 and _trigger_warning:
|
if _trigger_warning:
|
||||||
warn_deprecation(
|
warn_deprecation(
|
||||||
"annotate is intended for use in Python 2 only, as you can use type annotations Python 3.\n"
|
"annotate is intended for use in Python 2 only, as you can use type annotations Python 3.\n"
|
||||||
"Read more in https://docs.python.org/3/library/typing.html"
|
"Read more in https://docs.python.org/3/library/typing.html"
|
||||||
|
|
|
@ -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
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -55,7 +55,6 @@ tests_require = [
|
||||||
"snapshottest",
|
"snapshottest",
|
||||||
"coveralls",
|
"coveralls",
|
||||||
"promise",
|
"promise",
|
||||||
"six",
|
|
||||||
"mock",
|
"mock",
|
||||||
"pytz",
|
"pytz",
|
||||||
"iso8601",
|
"iso8601",
|
||||||
|
@ -86,7 +85,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>=2,<3",
|
"graphql-relay>=2,<3",
|
||||||
"aniso8601>=3,<=7",
|
"aniso8601>=3,<=7",
|
||||||
|
|
Loading…
Reference in New Issue
Block a user