Skip to content

Commit 7aa4b4b

Browse files
committed
Run black to format all quotes
1 parent a123405 commit 7aa4b4b

File tree

89 files changed

+875
-876
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+875
-876
lines changed

bin/shopify_api.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
project_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
99
sys.path.insert(0, project_root)
1010

11-
with open(os.path.join(project_root, 'scripts', 'shopify_api.py')) as f:
12-
code = compile(f.read(), f.name, 'exec')
11+
with open(os.path.join(project_root, "scripts", "shopify_api.py")) as f:
12+
code = compile(f.read(), f.name, "exec")
1313
exec(code)

pyproject.toml

-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,3 @@ max_line_length = 120
33

44
[tool.black]
55
line-length = 120
6-
skip-string-normalization = true

scripts/shopify_api.py

+10-10
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
def start_interpreter(**variables):
1717
# add the current working directory to the sys paths
1818
sys.path.append(os.getcwd())
19-
console = type('shopify ' + shopify.version.VERSION, (code.InteractiveConsole, object), {})
19+
console = type("shopify " + shopify.version.VERSION, (code.InteractiveConsole, object), {})
2020
import readline
2121

2222
console(variables).interact()
@@ -54,7 +54,7 @@ def filter_func(item):
5454
return cls
5555

5656
def run_task(cls, task=None, *args):
57-
if task in [None, '-h', '--help']:
57+
if task in [None, "-h", "--help"]:
5858
cls.help()
5959
return
6060

@@ -120,22 +120,22 @@ def add(cls, connection):
120120
if os.path.exists(filename):
121121
raise ConfigFileError("There is already a config file at " + filename)
122122
else:
123-
config = dict(protocol='https')
123+
config = dict(protocol="https")
124124
domain = input("Domain? (leave blank for %s.myshopify.com) " % (connection))
125125
if not domain.strip():
126126
domain = "%s.myshopify.com" % (connection)
127-
config['domain'] = domain
127+
config["domain"] = domain
128128
print("")
129129
print("open https://%s/admin/apps/private in your browser to generate API credentials" % (domain))
130-
config['api_key'] = input("API key? ")
131-
config['password'] = input("Password? ")
132-
config['api_version'] = input("API version? (leave blank for %s) " % (cls._default_api_version))
133-
if not config['api_version'].strip():
134-
config['api_version'] = cls._default_api_version
130+
config["api_key"] = input("API key? ")
131+
config["password"] = input("Password? ")
132+
config["api_version"] = input("API version? (leave blank for %s) " % (cls._default_api_version))
133+
if not config["api_version"].strip():
134+
config["api_version"] = cls._default_api_version
135135

136136
if not os.path.isdir(cls._shop_config_dir):
137137
os.makedirs(cls._shop_config_dir)
138-
with open(filename, 'w') as f:
138+
with open(filename, "w") as f:
139139
f.write(yaml.dump(config, default_flow_style=False, explicit_start="---"))
140140
if len(list(cls._available_connections())) == 1:
141141
cls.default(connection)

setup.py

+31-31
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
from setuptools import setup
22

3-
NAME = 'ShopifyAPI'
4-
exec(open('shopify/version.py').read())
5-
DESCRIPTION = 'Shopify API for Python'
3+
NAME = "ShopifyAPI"
4+
exec(open("shopify/version.py").read())
5+
DESCRIPTION = "Shopify API for Python"
66
LONG_DESCRIPTION = """\
77
The ShopifyAPI library allows python developers to programmatically
88
access the admin section of stores using an ActiveResource like
@@ -15,38 +15,38 @@
1515
version=VERSION,
1616
description=DESCRIPTION,
1717
long_description=LONG_DESCRIPTION,
18-
author='Shopify',
19-
author_email='[email protected]',
20-
url='https://github.com/Shopify/shopify_python_api',
21-
packages=['shopify', 'shopify/resources'],
22-
scripts=['scripts/shopify_api.py'],
23-
license='MIT License',
18+
author="Shopify",
19+
author_email="[email protected]",
20+
url="https://github.com/Shopify/shopify_python_api",
21+
packages=["shopify", "shopify/resources"],
22+
scripts=["scripts/shopify_api.py"],
23+
license="MIT License",
2424
install_requires=[
25-
'pyactiveresource>=2.2.2',
26-
'PyYAML',
27-
'six',
25+
"pyactiveresource>=2.2.2",
26+
"PyYAML",
27+
"six",
2828
],
29-
test_suite='test',
29+
test_suite="test",
3030
tests_require=[
31-
'mock>=1.0.1',
31+
"mock>=1.0.1",
3232
],
33-
platforms='Any',
33+
platforms="Any",
3434
classifiers=[
35-
'Development Status :: 5 - Production/Stable',
36-
'Intended Audience :: Developers',
37-
'License :: OSI Approved :: MIT License',
38-
'Operating System :: OS Independent',
39-
'Programming Language :: Python',
40-
'Programming Language :: Python :: 2',
41-
'Programming Language :: Python :: 2.7',
42-
'Programming Language :: Python :: 3',
43-
'Programming Language :: Python :: 3.4',
44-
'Programming Language :: Python :: 3.5',
45-
'Programming Language :: Python :: 3.6',
46-
'Programming Language :: Python :: 3.8',
47-
'Programming Language :: Python :: 3.9',
48-
'Topic :: Software Development',
49-
'Topic :: Software Development :: Libraries',
50-
'Topic :: Software Development :: Libraries :: Python Modules',
35+
"Development Status :: 5 - Production/Stable",
36+
"Intended Audience :: Developers",
37+
"License :: OSI Approved :: MIT License",
38+
"Operating System :: OS Independent",
39+
"Programming Language :: Python",
40+
"Programming Language :: Python :: 2",
41+
"Programming Language :: Python :: 2.7",
42+
"Programming Language :: Python :: 3",
43+
"Programming Language :: Python :: 3.4",
44+
"Programming Language :: Python :: 3.5",
45+
"Programming Language :: Python :: 3.6",
46+
"Programming Language :: Python :: 3.8",
47+
"Programming Language :: Python :: 3.9",
48+
"Topic :: Software Development",
49+
"Topic :: Software Development :: Libraries",
50+
"Topic :: Software Development :: Libraries :: Python Modules",
5151
],
5252
)

shopify/api_version.py

+11-11
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ def define_version(cls, version):
3030
def define_known_versions(cls):
3131
req = request.urlopen("https://app.shopify.com/services/apis.json")
3232
data = json.loads(req.read().decode("utf-8"))
33-
for api in data['apis']:
34-
if api['handle'] == 'admin':
35-
for release in api['versions']:
36-
if release['handle'] == 'unstable':
33+
for api in data["apis"]:
34+
if api["handle"] == "admin":
35+
for release in api["versions"]:
36+
if release["handle"] == "unstable":
3737
cls.define_version(Unstable())
3838
else:
39-
cls.define_version(Release(release['handle']))
39+
cls.define_version(Release(release["handle"]))
4040

4141
@classmethod
4242
def clear_defined_versions(cls):
@@ -60,15 +60,15 @@ def __eq__(self, other):
6060

6161

6262
class Release(ApiVersion):
63-
FORMAT = re.compile(r'^\d{4}-\d{2}$')
64-
API_PREFIX = '/admin/api'
63+
FORMAT = re.compile(r"^\d{4}-\d{2}$")
64+
API_PREFIX = "/admin/api"
6565

6666
def __init__(self, version_number):
6767
if not self.FORMAT.match(version_number):
6868
raise InvalidVersionError
6969
self._name = version_number
70-
self._numeric_version = int(version_number.replace('-', ''))
71-
self._path = '%s/%s' % (self.API_PREFIX, version_number)
70+
self._numeric_version = int(version_number.replace("-", ""))
71+
self._path = "%s/%s" % (self.API_PREFIX, version_number)
7272

7373
@property
7474
def stable(self):
@@ -77,9 +77,9 @@ def stable(self):
7777

7878
class Unstable(ApiVersion):
7979
def __init__(self):
80-
self._name = 'unstable'
80+
self._name = "unstable"
8181
self._numeric_version = 9000000
82-
self._path = '/admin/api/unstable'
82+
self._path = "/admin/api/unstable"
8383

8484
@property
8585
def stable(self):

shopify/base.py

+23-23
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class ShopifyResourceMeta(ResourceMeta):
3838
def connection(cls):
3939
"""HTTP connection for the current thread"""
4040
local = cls._threadlocal
41-
if not getattr(local, 'connection', None):
41+
if not getattr(local, "connection", None):
4242
# Make sure these variables are no longer affected by other threads.
4343
local.user = cls.user
4444
local.password = cls.password
@@ -54,7 +54,7 @@ def connection(cls):
5454
return local.connection
5555

5656
def get_user(cls):
57-
return getattr(cls._threadlocal, 'user', ShopifyResource._user)
57+
return getattr(cls._threadlocal, "user", ShopifyResource._user)
5858

5959
def set_user(cls, value):
6060
cls._threadlocal.connection = None
@@ -63,7 +63,7 @@ def set_user(cls, value):
6363
user = property(get_user, set_user, None, "The username for HTTP Basic Auth.")
6464

6565
def get_password(cls):
66-
return getattr(cls._threadlocal, 'password', ShopifyResource._password)
66+
return getattr(cls._threadlocal, "password", ShopifyResource._password)
6767

6868
def set_password(cls, value):
6969
cls._threadlocal.connection = None
@@ -72,7 +72,7 @@ def set_password(cls, value):
7272
password = property(get_password, set_password, None, "The password for HTTP Basic Auth.")
7373

7474
def get_site(cls):
75-
return getattr(cls._threadlocal, 'site', ShopifyResource._site)
75+
return getattr(cls._threadlocal, "site", ShopifyResource._site)
7676

7777
def set_site(cls, value):
7878
cls._threadlocal.connection = None
@@ -82,49 +82,49 @@ def set_site(cls, value):
8282
host = parts.hostname
8383
if parts.port:
8484
host += ":" + str(parts.port)
85-
new_site = urllib.parse.urlunparse((parts.scheme, host, parts.path, '', '', ''))
85+
new_site = urllib.parse.urlunparse((parts.scheme, host, parts.path, "", "", ""))
8686
ShopifyResource._site = cls._threadlocal.site = new_site
8787
if parts.username:
8888
cls.user = urllib.parse.unquote(parts.username)
8989
if parts.password:
9090
cls.password = urllib.parse.unquote(parts.password)
9191

92-
site = property(get_site, set_site, None, 'The base REST site to connect to.')
92+
site = property(get_site, set_site, None, "The base REST site to connect to.")
9393

9494
def get_timeout(cls):
95-
return getattr(cls._threadlocal, 'timeout', ShopifyResource._timeout)
95+
return getattr(cls._threadlocal, "timeout", ShopifyResource._timeout)
9696

9797
def set_timeout(cls, value):
9898
cls._threadlocal.connection = None
9999
ShopifyResource._timeout = cls._threadlocal.timeout = value
100100

101-
timeout = property(get_timeout, set_timeout, None, 'Socket timeout for HTTP requests')
101+
timeout = property(get_timeout, set_timeout, None, "Socket timeout for HTTP requests")
102102

103103
def get_headers(cls):
104-
if not hasattr(cls._threadlocal, 'headers'):
104+
if not hasattr(cls._threadlocal, "headers"):
105105
cls._threadlocal.headers = ShopifyResource._headers.copy()
106106
return cls._threadlocal.headers
107107

108108
def set_headers(cls, value):
109109
cls._threadlocal.headers = value
110110

111-
headers = property(get_headers, set_headers, None, 'The headers sent with HTTP requests')
111+
headers = property(get_headers, set_headers, None, "The headers sent with HTTP requests")
112112

113113
def get_format(cls):
114-
return getattr(cls._threadlocal, 'format', ShopifyResource._format)
114+
return getattr(cls._threadlocal, "format", ShopifyResource._format)
115115

116116
def set_format(cls, value):
117117
cls._threadlocal.connection = None
118118
ShopifyResource._format = cls._threadlocal.format = value
119119

120-
format = property(get_format, set_format, None, 'Encoding used for request and responses')
120+
format = property(get_format, set_format, None, "Encoding used for request and responses")
121121

122122
def get_prefix_source(cls):
123123
"""Return the prefix source, by default derived from site."""
124124
try:
125125
return cls.override_prefix()
126126
except AttributeError:
127-
if hasattr(cls, '_prefix_source'):
127+
if hasattr(cls, "_prefix_source"):
128128
return cls.site + cls._prefix_source
129129
else:
130130
return cls.site
@@ -133,33 +133,33 @@ def set_prefix_source(cls, value):
133133
"""Set the prefix source, which will be rendered into the prefix."""
134134
cls._prefix_source = value
135135

136-
prefix_source = property(get_prefix_source, set_prefix_source, None, 'prefix for lookups for this type of object.')
136+
prefix_source = property(get_prefix_source, set_prefix_source, None, "prefix for lookups for this type of object.")
137137

138138
def get_version(cls):
139-
if hasattr(cls._threadlocal, 'version') or ShopifyResource._version:
140-
return getattr(cls._threadlocal, 'version', ShopifyResource._version)
139+
if hasattr(cls._threadlocal, "version") or ShopifyResource._version:
140+
return getattr(cls._threadlocal, "version", ShopifyResource._version)
141141
elif ShopifyResource._site is not None:
142-
return ShopifyResource._site.split('/')[-1]
142+
return ShopifyResource._site.split("/")[-1]
143143

144144
def set_version(cls, value):
145145
ShopifyResource._version = cls._threadlocal.version = value
146146

147-
version = property(get_version, set_version, None, 'Shopify Api Version')
147+
version = property(get_version, set_version, None, "Shopify Api Version")
148148

149149
def get_url(cls):
150-
return getattr(cls._threadlocal, 'url', ShopifyResource._url)
150+
return getattr(cls._threadlocal, "url", ShopifyResource._url)
151151

152152
def set_url(cls, value):
153153
ShopifyResource._url = cls._threadlocal.url = value
154154

155-
url = property(get_url, set_url, None, 'Base URL including protocol and shopify domain')
155+
url = property(get_url, set_url, None, "Base URL including protocol and shopify domain")
156156

157157

158158
@six.add_metaclass(ShopifyResourceMeta)
159159
class ShopifyResource(ActiveResource, mixins.Countable):
160160
_format = formats.JSONFormat
161161
_threadlocal = threading.local()
162-
_headers = {'User-Agent': 'ShopifyPythonAPI/%s Python/%s' % (shopify.VERSION, sys.version.split(' ', 1)[0])}
162+
_headers = {"User-Agent": "ShopifyPythonAPI/%s Python/%s" % (shopify.VERSION, sys.version.split(" ", 1)[0])}
163163
_version = None
164164
_url = None
165165

@@ -182,7 +182,7 @@ def activate_session(cls, session):
182182
cls.user = None
183183
cls.password = None
184184
cls.version = session.api_version.name
185-
cls.headers['X-Shopify-Access-Token'] = session.token
185+
cls.headers["X-Shopify-Access-Token"] = session.token
186186

187187
@classmethod
188188
def clear_session(cls):
@@ -191,7 +191,7 @@ def clear_session(cls):
191191
cls.user = None
192192
cls.password = None
193193
cls.version = None
194-
cls.headers.pop('X-Shopify-Access-Token', None)
194+
cls.headers.pop("X-Shopify-Access-Token", None)
195195

196196
@classmethod
197197
def find(cls, id_=None, from_=None, **kwargs):

shopify/collection.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ def __init__(self, *args, **kwargs):
3030
super(PaginatedCollection, self).__init__(metadata=metadata or {}, *args, **kwargs)
3131

3232
if not ("resource_class" in self.metadata):
33-
raise AttributeError("Cursor-based pagination requires a \"resource_class\" attribute in the metadata.")
33+
raise AttributeError('Cursor-based pagination requires a "resource_class" attribute in the metadata.')
3434

3535
self.metadata["pagination"] = self.__parse_pagination()
36-
self.next_page_url = self.metadata["pagination"].get('next', None)
37-
self.previous_page_url = self.metadata["pagination"].get('previous', None)
36+
self.next_page_url = self.metadata["pagination"].get("next", None)
37+
self.previous_page_url = self.metadata["pagination"].get("previous", None)
3838

3939
self._next = None
4040
self._previous = None

shopify/limits.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class Limits(object):
1111

1212
# num_requests_executed/max_requests
1313
# Eg: 1/40
14-
CREDIT_LIMIT_HEADER_PARAM = 'X-Shopify-Shop-Api-Call-Limit'
14+
CREDIT_LIMIT_HEADER_PARAM = "X-Shopify-Shop-Api-Call-Limit"
1515

1616
@classmethod
1717
def response(cls):
@@ -22,14 +22,14 @@ def response(cls):
2222
@classmethod
2323
def api_credit_limit_param(cls):
2424
response = cls.response()
25-
_safe_header = getattr(response, "headers", '')
25+
_safe_header = getattr(response, "headers", "")
2626

2727
if not _safe_header:
2828
raise Exception("No shopify headers found")
2929

3030
if cls.CREDIT_LIMIT_HEADER_PARAM in response.headers:
3131
credits = response.headers[cls.CREDIT_LIMIT_HEADER_PARAM]
32-
return credits.split('/')
32+
return credits.split("/")
3333
else:
3434
raise Exception("No valid api call header found")
3535

shopify/resources/api_permission.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
class ApiPermission(ShopifyResource):
55
@classmethod
66
def delete(cls):
7-
cls.connection.delete(cls.site + '/api_permissions/current.' + cls.format.extension, cls.headers)
7+
cls.connection.delete(cls.site + "/api_permissions/current." + cls.format.extension, cls.headers)
88

99
destroy = delete

0 commit comments

Comments
 (0)