Skip to content

Commit f602e30

Browse files
committed
Use six to define a metaclass in a python 2 and 3 compatible way.
1 parent 6e0f5ef commit f602e30

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

scripts/shopify_api.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import glob
99
import subprocess
1010
import yaml
11+
import six
1112

1213
def start_interpreter(**variables):
1314
console = type('shopify ' + shopify.version.VERSION, (code.InteractiveConsole, object), {})
@@ -83,9 +84,8 @@ def help(cls, task=None):
8384
print(task_func.__doc__)
8485

8586

87+
@six.add_metaclass(TasksMeta)
8688
class Tasks(object):
87-
__metaclass__ = TasksMeta
88-
8989
_shop_config_dir = os.path.join(os.environ["HOME"], ".shopify", "shops")
9090
_default_symlink = os.path.join(_shop_config_dir, "default")
9191

shopify/base.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import threading
77
import sys
88
from six.moves import urllib
9+
import six
910

1011

1112
# Store the response from the last request in the connection object
@@ -114,8 +115,8 @@ def set_format(cls, value):
114115
'Encoding used for request and responses')
115116

116117

118+
@six.add_metaclass(ShopifyResourceMeta)
117119
class ShopifyResource(ActiveResource, mixins.Countable):
118-
__metaclass__ = ShopifyResourceMeta
119120
_format = formats.JSONFormat
120121
_threadlocal = threading.local()
121122
_headers = {'User-Agent': 'ShopifyPythonAPI/%s Python/%s' % (shopify.VERSION, sys.version.split(' ', 1)[0])}

0 commit comments

Comments
 (0)