Skip to content

Commit 5a0b574

Browse files
committed
Upgrade Python syntax with pyupgrade https://github.com/asottile/pyupgrade
1 parent c4305a6 commit 5a0b574

5 files changed

Lines changed: 12 additions & 12 deletions

File tree

examples/live_sendgrid_example.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
host = "https://api.sendgrid.com"
66
api_key = os.environ.get('SENDGRID_API_KEY')
77
request_headers = {
8-
"Authorization": 'Bearer {0}'.format(api_key)
8+
"Authorization": 'Bearer {}'.format(api_key)
99
}
1010
version = 3 # we could also use client.version(3)
1111
client = python_http_client.Client(host=host,

python_http_client/client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def _build_versioned_url(self, url):
102102
:type url: string
103103
:return: string
104104
"""
105-
return '{0}/v{1}{2}'.format(self.host, str(self._version), url)
105+
return '{}/v{}{}'.format(self.host, str(self._version), url)
106106

107107
def _build_url(self, query_params):
108108
"""Build the final URL to be passed to urllib
@@ -114,7 +114,7 @@ def _build_url(self, query_params):
114114
url = ''
115115
count = 0
116116
while count < len(self._url_path):
117-
url += '/{0}'.format(self._url_path[count])
117+
url += '/{}'.format(self._url_path[count])
118118
count += 1
119119

120120
# add slash
@@ -123,7 +123,7 @@ def _build_url(self, query_params):
123123

124124
if query_params:
125125
url_values = urlencode(sorted(query_params.items()), True)
126-
url = '{0}?{1}'.format(url, url_values)
126+
url = '{}?{}'.format(url, url_values)
127127

128128
if self._version:
129129
url = self._build_versioned_url(url)

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
version=version,
1515
author='Elmer Thomas',
1616
author_email='[email protected]',
17-
url='{0}python-http-client'.format(base_url),
18-
download_url='{0}python-http-client/tarball/{1}'.format(base_url, version),
17+
url='{}python-http-client'.format(base_url),
18+
download_url='{}python-http-client/tarball/{}'.format(base_url, version),
1919
packages=['python_http_client'],
2020
license='MIT',
2121
description='HTTP REST client, simplified for Python',

tests/profile.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,13 +131,13 @@ def run_tested_code(client, num_loops):
131131

132132
@timefunc
133133
def dynamic_version():
134-
local_path = '{0}/..'.format(os.path.abspath(os.path.dirname(__file__)))
134+
local_path = '{}/..'.format(os.path.abspath(os.path.dirname(__file__)))
135135
Config(local_path)
136136
api_key = os.environ.get('SENDGRID_API_KEY')
137137
request_headers = {
138138
'X-Mock': 200,
139139
'Content-Type': 'application/json',
140-
'Authorization': 'Bearer {0}'.format(api_key)
140+
'Authorization': 'Bearer {}'.format(api_key)
141141
}
142142
client = Client(host=os.environ.get('LOCAL_HOST'),
143143
request_headers=request_headers,
@@ -147,13 +147,13 @@ def dynamic_version():
147147

148148
@timefunc
149149
def static_version():
150-
local_path = '{0}/..'.format(os.path.abspath(os.path.dirname(__file__)))
150+
local_path = '{}/..'.format(os.path.abspath(os.path.dirname(__file__)))
151151
Config(local_path)
152152
api_key = os.environ.get('SENDGRID_API_KEY')
153153
request_headers = {
154154
'X-Mock': 200,
155155
'Content-Type': 'application/json',
156-
'Authorization': 'Bearer {0}'.format(api_key)
156+
'Authorization': 'Bearer {}'.format(api_key)
157157
}
158158
client = StaticClient(host=os.environ.get('LOCAL_HOST'),
159159
request_headers=request_headers,

tests/test_unit.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,15 +103,15 @@ def test__init__(self):
103103
def test__build_versioned_url(self):
104104
url = '/api_keys?hello=1&world=2'
105105
versioned_url = self.client._build_versioned_url(url)
106-
url = '{0}/v{1}{2}'.format(self.host, str(self.client._version), url)
106+
url = '{}/v{}{}'.format(self.host, str(self.client._version), url)
107107
self.assertEqual(versioned_url, url)
108108

109109
def test__build_url(self):
110110
self.client._url_path = self.client._url_path + ['here']
111111
self.client._url_path = self.client._url_path + ['there']
112112
self.client._url_path = self.client._url_path + [1]
113113
self.client._version = 3
114-
url = '{0}/v{1}{2}'.format(
114+
url = '{}/v{}{}'.format(
115115
self.host,
116116
str(self.client._version),
117117
'/here/there/1?hello=0&world=1&ztest=0&ztest=1'

0 commit comments

Comments
 (0)