Skip to content

Commit c4d3804

Browse files
committed
Use six instead of graphql.core.compat.
Closes #13
1 parent 263215f commit c4d3804

File tree

6 files changed

+14
-43
lines changed

6 files changed

+14
-43
lines changed

graphql/core/compat.py

Lines changed: 0 additions & 25 deletions
This file was deleted.

graphql/core/defer.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
# THE SOFTWARE.
6262
import collections
6363
import sys
64-
from graphql.core.compat import PY3
64+
from six import reraise
6565

6666
__all__ = ("Deferred", "AlreadyCalledDeferred", "DeferredException",
6767
"defer", "succeed", "fail", "DeferredDict", "DeferredList")
@@ -107,14 +107,9 @@ def __init__(self, type=None, value=None, traceback=None):
107107
elif not type or not value:
108108
self.type, self.value, self.traceback = sys.exc_info()
109109

110-
if PY3:
111-
def raise_exception(self):
112-
"""Raise the stored exception."""
113-
raise self.type(self.value).with_traceback(self.traceback)
114-
115-
else:
116-
exec("""def raise_exception(self):
117-
raise self.type, self.value, self.traceback""")
110+
def raise_exception(self):
111+
"""Raise the stored exception."""
112+
reraise(self.type, self.value, self.traceback)
118113

119114
def catch(self, *errors):
120115
"""Check if the stored exception is a subclass of one of the

graphql/core/execution/values.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import collections
2-
from ..compat import str_type
2+
from six import string_types
33
from ..error import GraphQLError
44
from ..language.printer import print_ast
55
from ..type import (
@@ -103,7 +103,7 @@ def is_valid_value(type, value):
103103

104104
if isinstance(type, GraphQLList):
105105
item_type = type.of_type
106-
if not isinstance(value, str_type) and \
106+
if not isinstance(value, string_types) and \
107107
isinstance(value, collections.Iterable):
108108
return all(is_valid_value(item_type, item) for item in value)
109109
else:
@@ -143,7 +143,7 @@ def coerce_value(type, value):
143143

144144
if isinstance(type, GraphQLList):
145145
item_type = type.of_type
146-
if not isinstance(value, str_type) and isinstance(value, collections.Iterable):
146+
if not isinstance(value, string_types) and isinstance(value, collections.Iterable):
147147
return [coerce_value(item_type, item) for item in value]
148148
else:
149149
return [coerce_value(item_type, value)]

graphql/core/language/lexer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import json
2-
from ..compat import unichr
2+
from six import unichr
33
from .error import LanguageError
44

55
__all__ = ['Token', 'Lexer', 'TokenKind',

graphql/core/language/parser.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
from six import string_types
12
from . import ast
2-
from ..compat import str_type
33
from .error import LanguageError
44
from .lexer import Lexer, TokenKind, get_token_desc, get_token_kind_desc
55
from .source import Source
@@ -13,7 +13,7 @@ def parse(source, **kwargs):
1313
options.update(kwargs)
1414
source_obj = source
1515

16-
if isinstance(source, str_type):
16+
if isinstance(source, string_types):
1717
source_obj = Source(source)
1818

1919
parser = Parser(source_obj, options)
@@ -25,7 +25,7 @@ def parse_value(source, **kwargs):
2525
options.update(kwargs)
2626
source_obj = source
2727

28-
if isinstance(source, str_type):
28+
if isinstance(source, string_types):
2929
source_obj = Source(source)
3030

3131
parser = Parser(source_obj, options)

graphql/core/utils/ast_from_value.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import json
22
import re
33
import sys
4-
from ..compat import str_type
4+
5+
from six import string_types
56
from ..language import ast
67
from ..type.definition import (
78
GraphQLEnumType,
@@ -43,7 +44,7 @@ def ast_from_value(value, type=None):
4344

4445
return ast.FloatValue(string_num)
4546

46-
if isinstance(value, str_type):
47+
if isinstance(value, string_types):
4748
if isinstance(type, GraphQLEnumType) and re.match(r'^[_a-zA-Z][_a-zA-Z0-9]*$', value):
4849
return ast.EnumValue(value)
4950

0 commit comments

Comments
 (0)