Skip to content

Commit e3ca97f

Browse files
committed
drop "six" usage
1 parent 7229004 commit e3ca97f

File tree

12 files changed

+21
-41
lines changed

12 files changed

+21
-41
lines changed

CONTRIBUTING.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,4 @@ Please open an issue here if you encounter a specific bug with this API client l
55

66
General questions about the Shopify API and usage of this package (not necessarily a bug) should be posted on the [Shopify forums](https://ecommerce.shopify.com/c/shopify-apis-and-technology).
77

8-
For compatibility across Python 2 and Python 3, look into [Six](https://six.readthedocs.io/).
9-
108
When in doubt, post on the forum first. You'll likely have your questions answered more quickly if you post there; more people monitor the forum than Github.

pylintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ callbacks=cb_,_cb
335335

336336
# List of qualified module names which can have objects that can redefine
337337
# builtins.
338-
redefining-builtins-modules=six,six.moves,past.builtins,future.builtins,functools
338+
redefining-builtins-modules=future.builtins,functools
339339

340340

341341
[LOGGING]

scripts/shopify_api.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
import subprocess
1010
import functools
1111
import yaml
12-
import six
13-
from six.moves import input, map
1412

1513

1614
def start_interpreter(**variables):
@@ -106,8 +104,7 @@ def help(cls, task=None):
106104
print(task_func.__doc__)
107105

108106

109-
@six.add_metaclass(TasksMeta)
110-
class Tasks(object):
107+
class Tasks(metaclass=TasksMeta):
111108
_shop_config_dir = os.path.join(os.environ["HOME"], ".shopify", "shops")
112109
_default_symlink = os.path.join(_shop_config_dir, "default")
113110
_default_api_version = "unstable"

setup.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
"PyJWT >= 2.0.0",
2727
"PyYAML>=6.0.1; python_version>='3.12'",
2828
"PyYAML; python_version<'3.12'",
29-
"six",
3029
],
3130
test_suite="test",
3231
tests_require=[

shopify/api_access.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,6 @@
22
import sys
33

44

5-
def basestring_type():
6-
if sys.version_info[0] < 3: # Backwards compatibility for python < v3.0.0
7-
return basestring
8-
else:
9-
return str
10-
11-
125
class ApiAccessError(Exception):
136
pass
147

@@ -20,7 +13,7 @@ class ApiAccess:
2013
IMPLIED_SCOPE_RE = re.compile(r"\A(?P<unauthenticated>unauthenticated_)?write_(?P<resource>.*)\Z")
2114

2215
def __init__(self, scopes):
23-
if isinstance(scopes, basestring_type()):
16+
if isinstance(scopes, str):
2417
scopes = scopes.split(self.SCOPE_DELIMITER)
2518

2619
self.__store_scopes(scopes)

shopify/base.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
import shopify
66
import threading
77
import sys
8-
from six.moves import urllib
9-
import six
8+
import urllib.parse
109

1110
from shopify.collection import PaginatedCollection
1211
from pyactiveresource.collection import Collection
@@ -152,8 +151,7 @@ def set_url(cls, value):
152151
url = property(get_url, set_url, None, "Base URL including protocol and shopify domain")
153152

154153

155-
@six.add_metaclass(ShopifyResourceMeta)
156-
class ShopifyResource(ActiveResource, mixins.Countable):
154+
class ShopifyResource(ActiveResource, mixins.Countable, metaclass=ShopifyResourceMeta):
157155
_format = formats.JSONFormat
158156
_threadlocal = threading.local()
159157
_headers = {"User-Agent": "ShopifyPythonAPI/%s Python/%s" % (shopify.VERSION, sys.version.split(" ", 1)[0])}

shopify/resources/graphql.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
import json
2+
import urllib.error
3+
import urllib.request
4+
15
import shopify
26
from ..base import ShopifyResource
3-
from six.moves import urllib
4-
import json
57

68

79
class GraphQL:

shopify/resources/image.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from ..base import ShopifyResource
22
from ..resources import Metafield
3-
from six.moves import urllib
3+
import urllib.parse
44
import base64
55
import re
66

shopify/session.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import time
22
import hmac
33
import json
4+
import urllib.parse
5+
import urllib.request
46
from hashlib import sha256
57

68
try:
@@ -9,10 +11,8 @@
911
import json
1012
import re
1113
from contextlib import contextmanager
12-
from six.moves import urllib
1314
from shopify.api_access import ApiAccess
1415
from shopify.api_version import ApiVersion, Release, Unstable
15-
import six
1616

1717

1818
class ValidationException(Exception):
@@ -28,7 +28,7 @@ class Session(object):
2828

2929
@classmethod
3030
def setup(cls, **kwargs):
31-
for k, v in six.iteritems(kwargs):
31+
for k, v in kwargs.items():
3232
setattr(cls, k, v)
3333

3434
@classmethod
@@ -165,7 +165,7 @@ def __encoded_params_for_signature(cls, params):
165165
"""
166166

167167
def encoded_pairs(params):
168-
for k, v in six.iteritems(params):
168+
for k, v in params.items():
169169
if k == "hmac":
170170
continue
171171

shopify/session_token.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
11
import jwt
22
import re
3-
import six
43
import sys
4+
from urllib.parse import urljoin
55

66
from shopify.utils import shop_url
77

8-
if sys.version_info[0] < 3: # Backwards compatibility for python < v3.0.0
9-
from urlparse import urljoin
10-
else:
11-
from urllib.parse import urljoin
12-
13-
148
ALGORITHM = "HS256"
159
PREFIX = "Bearer "
1610
REQUIRED_FIELDS = ["iss", "dest", "sub", "jti", "sid"]
@@ -61,7 +55,7 @@ def _decode_session_token(session_token, api_key, secret):
6155
options={"require": REQUIRED_FIELDS},
6256
)
6357
except jwt.exceptions.PyJWTError as exception:
64-
six.raise_from(SessionTokenError(str(exception)), exception)
58+
raise SessionTokenError(str(exception)) from exception
6559

6660

6761
def _validate_issuer(decoded_payload):

0 commit comments

Comments
 (0)