Skip to content

Commit c5b772d

Browse files
committed
trivial: Prepare for pyupgrade pre-commit hook
This change is entirely automated save for the update of some mocks from 'io.open' to '__builtins__.open'). We are keeping this change separate from addition of the actual hook so that we can ignore the commit later. Change-Id: I0a9d8736632084473b57b57b693322447d7be519 Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
1 parent 3de6969 commit c5b772d

274 files changed

Lines changed: 1291 additions & 1325 deletions

File tree

Some content is hidden

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

doc/source/conf.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
#
32
# OpenStack Command Line Client documentation build configuration file, created
43
# by sphinx-quickstart on Wed May 16 12:05:58 2012.

doc/source/contributor/command-errors.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ raised that includes the name of the file that was attempted to be opened.
4545
public_key = parsed_args.public_key
4646
if public_key:
4747
try:
48-
with io.open(
48+
with open(
4949
os.path.expanduser(parsed_args.public_key),
5050
"rb"
5151
) as p:

openstackclient/api/api.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from openstackclient.i18n import _
2222

2323

24-
class KeystoneSession(object):
24+
class KeystoneSession:
2525
"""Wrapper for the Keystone Session
2626
2727
Restore some requests.session.Session compatibility;
@@ -40,7 +40,7 @@ def __init__(self, session=None, endpoint=None, **kwargs):
4040
requests on this API.
4141
"""
4242

43-
super(KeystoneSession, self).__init__()
43+
super().__init__()
4444

4545
# a requests.Session-style interface
4646
self.session = session
@@ -95,7 +95,7 @@ def __init__(
9595
requests on this API.
9696
"""
9797

98-
super(BaseAPI, self).__init__(session=session, endpoint=endpoint)
98+
super().__init__(session=session, endpoint=endpoint)
9999

100100
self.service_type = service_type
101101

@@ -303,7 +303,7 @@ def find(
303303
"""
304304

305305
try:
306-
ret = self._request('GET', "/%s/%s" % (path, value)).json()
306+
ret = self._request('GET', f"/{path}/{value}").json()
307307
except ks_exceptions.NotFound:
308308
kwargs = {attr: value}
309309
try:

openstackclient/api/compute_v2.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class APIv2(api.BaseAPI):
3030
"""Compute v2 API"""
3131

3232
def __init__(self, **kwargs):
33-
super(APIv2, self).__init__(**kwargs)
33+
super().__init__(**kwargs)
3434

3535
# Overrides
3636

@@ -76,7 +76,7 @@ def find(
7676
"""
7777

7878
try:
79-
ret = self._request('GET', "/%s/%s" % (path, value)).json()
79+
ret = self._request('GET', f"/{path}/{value}").json()
8080
if isinstance(ret, dict):
8181
# strip off the enclosing dict
8282
key = list(ret.keys())[0]
@@ -136,7 +136,7 @@ def floating_ip_add(
136136

137137
return self._request(
138138
"POST",
139-
"/%s/%s/action" % (url, server['id']),
139+
"/{}/{}/action".format(url, server['id']),
140140
json={'addFloatingIp': body},
141141
)
142142

@@ -180,7 +180,7 @@ def floating_ip_delete(
180180
url = "/os-floating-ips"
181181

182182
if floating_ip_id is not None:
183-
return self.delete('/%s/%s' % (url, floating_ip_id))
183+
return self.delete(f'/{url}/{floating_ip_id}')
184184

185185
return None
186186

@@ -248,7 +248,7 @@ def floating_ip_remove(
248248

249249
return self._request(
250250
"POST",
251-
"/%s/%s/action" % (url, server['id']),
251+
"/{}/{}/action".format(url, server['id']),
252252
json={'removeFloatingIp': body},
253253
)
254254

@@ -316,7 +316,7 @@ def host_set(
316316
else:
317317
return self._request(
318318
"PUT",
319-
"/%s/%s" % (url, host),
319+
f"/{url}/{host}",
320320
json=params,
321321
).json()
322322

@@ -398,7 +398,7 @@ def network_delete(
398398
value=network,
399399
)['id']
400400
if network is not None:
401-
return self.delete('/%s/%s' % (url, network))
401+
return self.delete(f'/{url}/{network}')
402402

403403
return None
404404

@@ -487,7 +487,7 @@ def security_group_delete(
487487
value=security_group,
488488
)['id']
489489
if security_group is not None:
490-
return self.delete('/%s/%s' % (url, security_group))
490+
return self.delete(f'/{url}/{security_group}')
491491

492492
return None
493493

@@ -535,7 +535,7 @@ def security_group_list(
535535

536536
params = {}
537537
if search_opts is not None:
538-
params = dict((k, v) for (k, v) in search_opts.items() if v)
538+
params = {k: v for (k, v) in search_opts.items() if v}
539539
if limit:
540540
params['limit'] = limit
541541
if marker:
@@ -549,7 +549,7 @@ def security_group_set(
549549
security_group=None,
550550
# name=None,
551551
# description=None,
552-
**params
552+
**params,
553553
):
554554
"""Update a security group
555555
@@ -579,7 +579,7 @@ def security_group_set(
579579
security_group[k] = v
580580
return self._request(
581581
"PUT",
582-
"/%s/%s" % (url, security_group['id']),
582+
"/{}/{}".format(url, security_group['id']),
583583
json={'security_group': security_group},
584584
).json()['security_group']
585585
return None
@@ -648,6 +648,6 @@ def security_group_rule_delete(
648648

649649
url = "/os-security-group-rules"
650650
if security_group_rule_id is not None:
651-
return self.delete('/%s/%s' % (url, security_group_rule_id))
651+
return self.delete(f'/{url}/{security_group_rule_id}')
652652

653653
return None

openstackclient/api/image_v1.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class APIv1(api.BaseAPI):
2222
_endpoint_suffix = '/v1'
2323

2424
def __init__(self, endpoint=None, **kwargs):
25-
super(APIv1, self).__init__(endpoint=endpoint, **kwargs)
25+
super().__init__(endpoint=endpoint, **kwargs)
2626

2727
self.endpoint = self.endpoint.rstrip('/')
2828
self._munge_url()

openstackclient/api/object_store_v1.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
"""Object Store v1 API Library"""
1515

16-
import io
1716
import logging
1817
import os
1918
import sys
@@ -33,7 +32,7 @@ class APIv1(api.BaseAPI):
3332
"""Object Store v1 API"""
3433

3534
def __init__(self, **kwargs):
36-
super(APIv1, self).__init__(**kwargs)
35+
super().__init__(**kwargs)
3736

3837
def container_create(
3938
self, container=None, public=False, storage_policy=None
@@ -257,11 +256,11 @@ def object_create(
257256
# object's name in the container.
258257
object_name_str = name if name else object
259258

260-
full_url = "%s/%s" % (
259+
full_url = "{}/{}".format(
261260
urllib.parse.quote(container),
262261
urllib.parse.quote(object_name_str),
263262
)
264-
with io.open(object, 'rb') as f:
263+
with open(object, 'rb') as f:
265264
response = self.create(
266265
full_url,
267266
method='PUT',

openstackclient/common/availability_zone.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def _xform_compute_availability_zone(az, include_extra):
4747
for svc, state in services.items():
4848
info = copy.deepcopy(host_info)
4949
info['service_name'] = svc
50-
info['service_status'] = '%s %s %s' % (
50+
info['service_status'] = '{} {} {}'.format(
5151
'enabled' if state['active'] else 'disabled',
5252
':-)' if state['available'] else 'XXX',
5353
state['updated_at'],

openstackclient/common/clientmanager.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def __init__(
5151
api_version=None,
5252
pw_func=None,
5353
):
54-
super(ClientManager, self).__init__(
54+
super().__init__(
5555
cli_options=cli_options,
5656
api_version=api_version,
5757
pw_func=pw_func,
@@ -94,7 +94,7 @@ def setup_auth(self):
9494
except TypeError as e:
9595
self._fallback_load_auth_plugin(e)
9696

97-
return super(ClientManager, self).setup_auth()
97+
return super().setup_auth()
9898

9999
def _fallback_load_auth_plugin(self, e):
100100
# NOTES(RuiChen): Hack to avoid auth plugins choking on data they don't
@@ -170,7 +170,9 @@ def get_plugin_modules(group):
170170
module = importlib.import_module(module_name)
171171
except Exception as err:
172172
sys.stderr.write(
173-
"WARNING: Failed to import plugin %s: %s.\n" % (ep.name, err)
173+
"WARNING: Failed to import plugin {}: {}.\n".format(
174+
ep.name, err
175+
)
174176
)
175177
continue
176178

openstackclient/common/configuration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class ShowConfiguration(command.ShowOne):
2727
auth_required = False
2828

2929
def get_parser(self, prog_name):
30-
parser = super(ShowConfiguration, self).get_parser(prog_name)
30+
parser = super().get_parser(prog_name)
3131
mask_group = parser.add_mutually_exclusive_group()
3232
mask_group.add_argument(
3333
"--mask",

openstackclient/common/extension.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ class ShowExtension(command.ShowOne):
148148
_description = _("Show API extension")
149149

150150
def get_parser(self, prog_name):
151-
parser = super(ShowExtension, self).get_parser(prog_name)
151+
parser = super().get_parser(prog_name)
152152
parser.add_argument(
153153
'extension',
154154
metavar='<extension>',

0 commit comments

Comments
 (0)