Skip to content

Commit af6396b

Browse files
authored
Remove six dependency (#986)
* No one is using func_name * Remove six simple usages * Remove six requirement * Remove `six.with_metaclass` calls
1 parent 6e2bb3b commit af6396b

File tree

9 files changed

+9
-34
lines changed

9 files changed

+9
-34
lines changed

graphene/pyutils/compat.py

-13
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,8 @@
11
from __future__ import absolute_import
22

3-
import six
4-
53
from graphql.pyutils.compat import Enum
64

75
try:
86
from inspect import signature
97
except ImportError:
108
from .signature import signature
11-
12-
if six.PY2:
13-
14-
def func_name(func):
15-
return func.func_name
16-
17-
18-
else:
19-
20-
def func_name(func):
21-
return func.__name__

graphene/test/__init__.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from promise import Promise, is_thenable
2-
import six
32
from graphql.error import format_error as format_graphql_error
43
from graphql.error import GraphQLError
54

@@ -10,7 +9,7 @@ def default_format_error(error):
109
if isinstance(error, GraphQLError):
1110
return format_graphql_error(error)
1211

13-
return {"message": six.text_type(error)}
12+
return {"message": str(error)}
1413

1514

1615
def format_execution_result(execution_result, format_error):

graphene/types/datetime.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
from aniso8601 import parse_date, parse_datetime, parse_time
66
from graphql.language import ast
7-
from six import string_types
87

98
from .scalars import Scalar
109

@@ -35,7 +34,7 @@ def parse_value(value):
3534
try:
3635
if isinstance(value, datetime.date):
3736
return value
38-
elif isinstance(value, string_types):
37+
elif isinstance(value, str):
3938
return parse_date(value)
4039
except ValueError:
4140
return None
@@ -65,7 +64,7 @@ def parse_value(value):
6564
try:
6665
if isinstance(value, datetime.datetime):
6766
return value
68-
elif isinstance(value, string_types):
67+
elif isinstance(value, str):
6968
return parse_datetime(value)
7069
except ValueError:
7170
return None
@@ -95,7 +94,7 @@ def parse_value(cls, value):
9594
try:
9695
if isinstance(value, datetime.time):
9796
return value
98-
elif isinstance(value, string_types):
97+
elif isinstance(value, str):
9998
return parse_time(value)
10099
except ValueError:
101100
return None

graphene/types/enum.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
from collections import OrderedDict
2-
3-
import six
4-
52
from graphene.utils.subclass_with_meta import SubclassWithMeta_Meta
63

74
from ..pyutils.compat import Enum as PyEnum
@@ -66,7 +63,7 @@ def from_enum(cls, enum, description=None, deprecation_reason=None): # noqa: N8
6663
return type(meta_class.enum.__name__, (Enum,), {"Meta": meta_class})
6764

6865

69-
class Enum(six.with_metaclass(EnumMeta, UnmountedType, BaseType)):
66+
class Enum(UnmountedType, BaseType, metaclass=EnumMeta):
7067
@classmethod
7168
def __init_subclass_with_meta__(cls, enum=None, _meta=None, **options):
7269
if not _meta:

graphene/types/scalars.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import six
21
from typing import Any
32

43
from graphql.language.ast import BooleanValue, FloatValue, IntValue, StringValue
@@ -113,7 +112,7 @@ class String(Scalar):
113112
def coerce_string(value):
114113
if isinstance(value, bool):
115114
return u"true" if value else u"false"
116-
return six.text_type(value)
115+
return str(value)
117116

118117
serialize = coerce_string
119118
parse_value = coerce_string

graphene/types/utils.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
from collections import OrderedDict
33
from functools import partial
44

5-
from six import string_types
6-
75
from ..utils.module_loading import import_string
86
from .mountedtype import MountedType
97
from .unmountedtype import UnmountedType
@@ -39,7 +37,7 @@ def yank_fields_from_attrs(attrs, _as=None, sort=True):
3937

4038

4139
def get_type(_type):
42-
if isinstance(_type, string_types):
40+
if isinstance(_type, str):
4341
return import_string(_type)
4442
if inspect.isfunction(_type) or isinstance(_type, partial):
4543
return _type()

graphene/types/uuid.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from __future__ import absolute_import
2-
import six
32
from uuid import UUID as _UUID
43

54
from graphql.language import ast
@@ -12,7 +11,7 @@ class UUID(Scalar):
1211

1312
@staticmethod
1413
def serialize(uuid):
15-
if isinstance(uuid, six.string_types):
14+
if isinstance(uuid, str):
1615
uuid = _UUID(uuid)
1716

1817
assert isinstance(uuid, _UUID), "Expected UUID instance, received {}".format(

graphene/utils/subclass_with_meta.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
from inspect import isclass
22

3-
import six
4-
53
from ..pyutils.init_subclass import InitSubclassMeta
64
from .props import props
75

@@ -18,7 +16,7 @@ def __repr__(cls):
1816
return "<{} meta={}>".format(cls.__name__, repr(cls._meta))
1917

2018

21-
class SubclassWithMeta(six.with_metaclass(SubclassWithMeta_Meta)):
19+
class SubclassWithMeta(metaclass=SubclassWithMeta_Meta):
2220
"""This class improves __init_subclass__ to receive automatically the options from meta"""
2321

2422
# We will only have the metaclass in Python 2

setup.py

-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ def run_tests(self):
7979
keywords="api graphql protocol rest relay graphene",
8080
packages=find_packages(exclude=["tests", "tests.*", "examples"]),
8181
install_requires=[
82-
"six>=1.10.0,<2",
8382
"graphql-core>=2.1,<3",
8483
"graphql-relay>=0.4.5,<1",
8584
"aniso8601>=3,<=6.0.*",

0 commit comments

Comments
 (0)