Merge "Bump pyupgrade target to 3.10+"
This commit is contained in:
@@ -27,4 +27,4 @@ repos:
|
|||||||
rev: v3.20.0
|
rev: v3.20.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: pyupgrade
|
- id: pyupgrade
|
||||||
args: [--py3-only]
|
args: [--py310-plus]
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ def gen_ref(ver, title, names):
|
|||||||
refdir = os.path.join(BASE_DIR, "ref")
|
refdir = os.path.join(BASE_DIR, "ref")
|
||||||
pkg = "heatclient"
|
pkg = "heatclient"
|
||||||
if ver:
|
if ver:
|
||||||
pkg = "{}.{}".format(pkg, ver)
|
pkg = f"{pkg}.{ver}"
|
||||||
refdir = os.path.join(refdir, ver)
|
refdir = os.path.join(refdir, ver)
|
||||||
if not os.path.exists(refdir):
|
if not os.path.exists(refdir):
|
||||||
os.makedirs(refdir)
|
os.makedirs(refdir)
|
||||||
|
|||||||
@@ -282,7 +282,7 @@ class CrudManager(BaseManager):
|
|||||||
url = '/'.join([url, self.collection_key])
|
url = '/'.join([url, self.collection_key])
|
||||||
|
|
||||||
# do we have a specific entity?
|
# do we have a specific entity?
|
||||||
entity_id = kwargs.get('{}_id'.format(self.key))
|
entity_id = kwargs.get(f'{self.key}_id')
|
||||||
if entity_id is not None:
|
if entity_id is not None:
|
||||||
url = '/'.join([url, entity_id])
|
url = '/'.join([url, entity_id])
|
||||||
|
|
||||||
@@ -322,7 +322,7 @@ class CrudManager(BaseManager):
|
|||||||
:param base_url: if provided, the generated URL will be appended to it
|
:param base_url: if provided, the generated URL will be appended to it
|
||||||
"""
|
"""
|
||||||
kwargs = self._filter_kwargs(kwargs)
|
kwargs = self._filter_kwargs(kwargs)
|
||||||
query = '?{}'.format(parse.urlencode(kwargs)) if kwargs else ''
|
query = f'?{parse.urlencode(kwargs)}' if kwargs else ''
|
||||||
|
|
||||||
return self._list(
|
return self._list(
|
||||||
'{base_url}{query}'.format(
|
'{base_url}{query}'.format(
|
||||||
@@ -343,7 +343,7 @@ class CrudManager(BaseManager):
|
|||||||
def update(self, **kwargs):
|
def update(self, **kwargs):
|
||||||
kwargs = self._filter_kwargs(kwargs)
|
kwargs = self._filter_kwargs(kwargs)
|
||||||
params = kwargs.copy()
|
params = kwargs.copy()
|
||||||
params.pop('{}_id'.format(self.key))
|
params.pop(f'{self.key}_id')
|
||||||
|
|
||||||
return self._patch(
|
return self._patch(
|
||||||
self.build_url(**kwargs),
|
self.build_url(**kwargs),
|
||||||
@@ -362,7 +362,7 @@ class CrudManager(BaseManager):
|
|||||||
:param base_url: if provided, the generated URL will be appended to it
|
:param base_url: if provided, the generated URL will be appended to it
|
||||||
"""
|
"""
|
||||||
kwargs = self._filter_kwargs(kwargs)
|
kwargs = self._filter_kwargs(kwargs)
|
||||||
query = '?{}'.format(parse.urlencode(kwargs)) if kwargs else ''
|
query = f'?{parse.urlencode(kwargs)}' if kwargs else ''
|
||||||
|
|
||||||
rl = self._list(
|
rl = self._list(
|
||||||
'{base_url}{query}'.format(
|
'{base_url}{query}'.format(
|
||||||
@@ -409,7 +409,7 @@ class Extension(HookableMixin):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "<Extension '{}'>".format(self.name)
|
return f"<Extension '{self.name}'>"
|
||||||
|
|
||||||
|
|
||||||
class Resource:
|
class Resource:
|
||||||
@@ -436,9 +436,9 @@ class Resource:
|
|||||||
reprkeys = sorted(k
|
reprkeys = sorted(k
|
||||||
for k in self.__dict__
|
for k in self.__dict__
|
||||||
if k[0] != '_' and k != 'manager')
|
if k[0] != '_' and k != 'manager')
|
||||||
info = ", ".join("{}={}".format(k, getattr(self, k)) for k in reprkeys)
|
info = ", ".join(f"{k}={getattr(self, k)}" for k in reprkeys)
|
||||||
class_name = reflection.get_class_name(self, fully_qualified=False)
|
class_name = reflection.get_class_name(self, fully_qualified=False)
|
||||||
return "<{} {}>".format(class_name, info)
|
return f"<{class_name} {info}>"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def human_id(self):
|
def human_id(self):
|
||||||
|
|||||||
@@ -105,12 +105,12 @@ def create_temp_url(swift_client, name, timeout, container=None):
|
|||||||
|
|
||||||
key = swift_client.head_account()[key_header]
|
key = swift_client.head_account()[key_header]
|
||||||
project_path = swift_client.url.split('/')[-1]
|
project_path = swift_client.url.split('/')[-1]
|
||||||
path = '/v1/{}/{}/{}'.format(project_path, container, object_name)
|
path = f'/v1/{project_path}/{container}/{object_name}'
|
||||||
timeout_secs = timeout * 60
|
timeout_secs = timeout * 60
|
||||||
tempurl = swiftclient_utils.generate_temp_url(path, timeout_secs, key,
|
tempurl = swiftclient_utils.generate_temp_url(path, timeout_secs, key,
|
||||||
'PUT')
|
'PUT')
|
||||||
sw_url = urlparse.urlparse(swift_client.url)
|
sw_url = urlparse.urlparse(swift_client.url)
|
||||||
put_url = '{}://{}{}'.format(sw_url.scheme, sw_url.netloc, tempurl)
|
put_url = f'{sw_url.scheme}://{sw_url.netloc}{tempurl}'
|
||||||
swift_client.put_object(container, object_name, '')
|
swift_client.put_object(container, object_name, '')
|
||||||
return put_url
|
return put_url
|
||||||
|
|
||||||
|
|||||||
@@ -261,4 +261,4 @@ def wait_for_events(ws, stack_name, out=None):
|
|||||||
if stack_status in ('COMPLETE', 'FAILED'):
|
if stack_status in ('COMPLETE', 'FAILED'):
|
||||||
msg = msg_template % dict(
|
msg = msg_template % dict(
|
||||||
name=stack_name, status=event.resource_status)
|
name=stack_name, status=event.resource_status)
|
||||||
return '{}_{}'.format(event.resource_action, stack_status), msg
|
return f'{event.resource_action}_{stack_status}', msg
|
||||||
|
|||||||
@@ -90,6 +90,6 @@ def print_software_deployment_output(data, name, out=sys.stdout, long=False):
|
|||||||
truncate=not long,
|
truncate=not long,
|
||||||
truncate_prefix='...',
|
truncate_prefix='...',
|
||||||
truncate_postfix='(truncated, view all with --long)')
|
truncate_postfix='(truncated, view all with --long)')
|
||||||
out.write(' {}: |\n{}\n'.format(name, output))
|
out.write(f' {name}: |\n{output}\n')
|
||||||
else:
|
else:
|
||||||
out.write(' {}: {}\n'.format(name, data.get(name)))
|
out.write(f' {name}: {data.get(name)}\n')
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ class HTTPClient:
|
|||||||
def log_http_response(resp):
|
def log_http_response(resp):
|
||||||
status = (resp.raw.version / 10.0, resp.status_code, resp.reason)
|
status = (resp.raw.version / 10.0, resp.status_code, resp.reason)
|
||||||
dump = ['\nHTTP/%.1f %s %s' % status]
|
dump = ['\nHTTP/%.1f %s %s' % status]
|
||||||
dump.extend(['{}: {}'.format(k, v) for k, v in resp.headers.items()])
|
dump.extend([f'{k}: {v}' for k, v in resp.headers.items()])
|
||||||
dump.append('')
|
dump.append('')
|
||||||
if resp.content:
|
if resp.content:
|
||||||
content = resp.content
|
content = resp.content
|
||||||
@@ -216,7 +216,7 @@ class HTTPClient:
|
|||||||
message = (_("Error finding address for %(url)s: %(e)s") %
|
message = (_("Error finding address for %(url)s: %(e)s") %
|
||||||
{'url': self.endpoint_url + url, 'e': e})
|
{'url': self.endpoint_url + url, 'e': e})
|
||||||
raise exc.InvalidEndpoint(message=message)
|
raise exc.InvalidEndpoint(message=message)
|
||||||
except (OSError, socket.timeout) as e:
|
except (OSError, TimeoutError) as e:
|
||||||
endpoint = self.endpoint
|
endpoint = self.endpoint
|
||||||
message = (_("Error communicating with %(endpoint)s %(e)s") %
|
message = (_("Error communicating with %(endpoint)s %(e)s") %
|
||||||
{'endpoint': endpoint, 'e': e})
|
{'endpoint': endpoint, 'e': e})
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ class ResourceDotInfo:
|
|||||||
if not prefix:
|
if not prefix:
|
||||||
prefix = 'r'
|
prefix = 'r'
|
||||||
hash_object = hashlib.sha256(url.encode('utf-8'))
|
hash_object = hashlib.sha256(url.encode('utf-8'))
|
||||||
return '{}_{}'.format(prefix, hash_object.hexdigest()[:20])
|
return f'{prefix}_{hash_object.hexdigest()[:20]}'
|
||||||
|
|
||||||
|
|
||||||
class ResourceDotFormatter(base.ListFormatter):
|
class ResourceDotFormatter(base.ListFormatter):
|
||||||
|
|||||||
@@ -592,7 +592,7 @@ class HeatShell:
|
|||||||
class HelpFormatter(argparse.HelpFormatter):
|
class HelpFormatter(argparse.HelpFormatter):
|
||||||
def start_section(self, heading):
|
def start_section(self, heading):
|
||||||
# Title-case the headings
|
# Title-case the headings
|
||||||
heading = '{}{}'.format(heading[0].upper(), heading[1:])
|
heading = f'{heading[0].upper()}{heading[1:]}'
|
||||||
super().start_section(heading)
|
super().start_section(heading)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -192,7 +192,7 @@ class TestCase(testtools.TestCase):
|
|||||||
"logical_resource_id": "myDeployment",
|
"logical_resource_id": "myDeployment",
|
||||||
"physical_resource_id": "bce15ec4-8919-4a02-8a90-680960fb3731",
|
"physical_resource_id": "bce15ec4-8919-4a02-8a90-680960fb3731",
|
||||||
"resource_name": rn,
|
"resource_name": rn,
|
||||||
"resource_status": "{}_{}".format(action, final_state),
|
"resource_status": f"{action}_{final_state}",
|
||||||
"resource_status_reason": "state changed"}]}
|
"resource_status_reason": "state changed"}]}
|
||||||
|
|
||||||
if resource_name is None:
|
if resource_name is None:
|
||||||
@@ -227,7 +227,7 @@ class TestCase(testtools.TestCase):
|
|||||||
"logical_resource_id": "aResource",
|
"logical_resource_id": "aResource",
|
||||||
"physical_resource_id": 'foo3',
|
"physical_resource_id": 'foo3',
|
||||||
"resource_name": stack_name,
|
"resource_name": stack_name,
|
||||||
"resource_status": "{}_{}".format(action, final_state),
|
"resource_status": f"{action}_{final_state}",
|
||||||
"resource_status_reason": "state changed"})
|
"resource_status_reason": "state changed"})
|
||||||
|
|
||||||
return resp_dict
|
return resp_dict
|
||||||
@@ -320,7 +320,7 @@ class ShellParamValidationTest(TestCase):
|
|||||||
|
|
||||||
if self.with_tmpl:
|
if self.with_tmpl:
|
||||||
template_file = os.path.join(TEST_VAR_DIR, 'minimal.template')
|
template_file = os.path.join(TEST_VAR_DIR, 'minimal.template')
|
||||||
cmd = '{} --template-file={} '.format(self.command, template_file)
|
cmd = f'{self.command} --template-file={template_file} '
|
||||||
|
|
||||||
self.shell_error(cmd, self.err, exception=exc.CommandError)
|
self.shell_error(cmd, self.err, exception=exc.CommandError)
|
||||||
|
|
||||||
@@ -2731,7 +2731,7 @@ class ShellTestEventsNested(ShellBase):
|
|||||||
stack_id = 'teststack/1'
|
stack_id = 'teststack/1'
|
||||||
error = self.assertRaises(
|
error = self.assertRaises(
|
||||||
exc.CommandError, self.shell,
|
exc.CommandError, self.shell,
|
||||||
'event-list {} --nested-depth Z'.format(stack_id))
|
f'event-list {stack_id} --nested-depth Z')
|
||||||
self.assertIn('--nested-depth invalid value Z', str(error))
|
self.assertIn('--nested-depth invalid value Z', str(error))
|
||||||
|
|
||||||
def test_shell_nested_depth_zero(self):
|
def test_shell_nested_depth_zero(self):
|
||||||
@@ -2955,7 +2955,7 @@ class ShellTestHookFunctions(ShellBase):
|
|||||||
resp_dict = {"stack": {
|
resp_dict = {"stack": {
|
||||||
"id": stack_id.split("/")[1],
|
"id": stack_id.split("/")[1],
|
||||||
"stack_name": stack_id.split("/")[0],
|
"stack_name": stack_id.split("/")[0],
|
||||||
"stack_status": '{}_{}'.format(action, status),
|
"stack_status": f'{action}_{status}',
|
||||||
"creation_time": "2014-01-06T16:14:00Z",
|
"creation_time": "2014-01-06T16:14:00Z",
|
||||||
}}
|
}}
|
||||||
self.mock_request_get('/stacks/teststack/1', resp_dict)
|
self.mock_request_get('/stacks/teststack/1', resp_dict)
|
||||||
@@ -3113,7 +3113,7 @@ class ShellTestResources(ShellBase):
|
|||||||
stack_id = 'teststack/1'
|
stack_id = 'teststack/1'
|
||||||
self.mock_request_get('/stacks/%s/resources' % stack_id, resp_dict)
|
self.mock_request_get('/stacks/%s/resources' % stack_id, resp_dict)
|
||||||
|
|
||||||
resource_list_text = self.shell('resource-list {}'.format(stack_id))
|
resource_list_text = self.shell(f'resource-list {stack_id}')
|
||||||
|
|
||||||
required = [
|
required = [
|
||||||
'physical_resource_id',
|
'physical_resource_id',
|
||||||
@@ -3147,7 +3147,7 @@ class ShellTestResources(ShellBase):
|
|||||||
stack_id = 'teststack/1'
|
stack_id = 'teststack/1'
|
||||||
self.mock_request_get('/stacks/%s/resources' % stack_id, resp_dict)
|
self.mock_request_get('/stacks/%s/resources' % stack_id, resp_dict)
|
||||||
|
|
||||||
resource_list_text = self.shell('resource-list {}'.format(stack_id))
|
resource_list_text = self.shell(f'resource-list {stack_id}')
|
||||||
|
|
||||||
self.assertEqual('''\
|
self.assertEqual('''\
|
||||||
+---------------+----------------------+---------------+-----------------+\
|
+---------------+----------------------+---------------+-----------------+\
|
||||||
@@ -3177,7 +3177,7 @@ class ShellTestResources(ShellBase):
|
|||||||
self.mock_request_get('/stacks/{}/resources?{}'.format(
|
self.mock_request_get('/stacks/{}/resources?{}'.format(
|
||||||
stack_id, query_args), resp_dict)
|
stack_id, query_args), resp_dict)
|
||||||
|
|
||||||
shell_cmd = 'resource-list {} {}'.format(stack_id, cmd_args)
|
shell_cmd = f'resource-list {stack_id} {cmd_args}'
|
||||||
|
|
||||||
resource_list_text = self.shell(shell_cmd)
|
resource_list_text = self.shell(shell_cmd)
|
||||||
|
|
||||||
@@ -3297,7 +3297,7 @@ class ShellTestResources(ShellBase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
text = self.shell(
|
text = self.shell(
|
||||||
'resource-signal {} {}'.format(stack_id, resource_name))
|
f'resource-signal {stack_id} {resource_name}')
|
||||||
self.assertEqual("", text)
|
self.assertEqual("", text)
|
||||||
|
|
||||||
def test_resource_signal_no_json(self):
|
def test_resource_signal_no_json(self):
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ class StackStatusActionTest(testtools.TestCase):
|
|||||||
])
|
])
|
||||||
|
|
||||||
def test_status_action(self):
|
def test_status_action(self):
|
||||||
stack_status = '{}_{}'.format(self.action, self.status)
|
stack_status = f'{self.action}_{self.status}'
|
||||||
stack = mock_stack(None, 'stack_1', 'abcd1234')
|
stack = mock_stack(None, 'stack_1', 'abcd1234')
|
||||||
stack.stack_status = stack_status
|
stack.stack_status = stack_status
|
||||||
self.assertEqual(self.action, stack.action)
|
self.assertEqual(self.action, stack.action)
|
||||||
|
|||||||
@@ -716,7 +716,7 @@ class TestGetTemplateContents(testtools.TestCase):
|
|||||||
|
|
||||||
def check_non_utf8_content(self, filename, content):
|
def check_non_utf8_content(self, filename, content):
|
||||||
base_url = 'file:///tmp'
|
base_url = 'file:///tmp'
|
||||||
url = '{}/{}'.format(base_url, filename)
|
url = f'{base_url}/{filename}'
|
||||||
template = {'resources':
|
template = {'resources':
|
||||||
{'one_init':
|
{'one_init':
|
||||||
{'type': 'OS::Heat::CloudConfig',
|
{'type': 'OS::Heat::CloudConfig',
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ class Stack(base.Resource):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def identifier(self):
|
def identifier(self):
|
||||||
return '{}/{}'.format(self.stack_name, self.id)
|
return f'{self.stack_name}/{self.id}'
|
||||||
|
|
||||||
|
|
||||||
class StackChildManager(base.BaseManager):
|
class StackChildManager(base.BaseManager):
|
||||||
|
|||||||
Reference in New Issue
Block a user