From 9dede4eb2b824b21c0031507bd986796f535810c Mon Sep 17 00:00:00 2001 From: Andreas Jaeger Date: Sat, 28 Mar 2020 15:38:59 +0100 Subject: Update hacking for Python3 The repo is Python 3 now, so update hacking to version 3.0 which supports Python 3. Fix problems found. Change-Id: I82c745f5b1236844deec4538be84037a64eebeee --- heatclient/common/event_utils.py | 4 ++-- heatclient/common/http.py | 2 +- heatclient/common/template_format.py | 2 ++ heatclient/common/utils.py | 4 ++-- heatclient/shell.py | 1 + heatclient/tests/unit/test_deployment_utils.py | 6 +++--- heatclient/tests/unit/test_shell.py | 4 ++-- heatclient/v1/shell.py | 2 +- 8 files changed, 14 insertions(+), 11 deletions(-) (limited to 'heatclient') diff --git a/heatclient/common/event_utils.py b/heatclient/common/event_utils.py index 8551b56..c4095b6 100644 --- a/heatclient/common/event_utils.py +++ b/heatclient/common/event_utils.py @@ -182,9 +182,9 @@ def poll_for_events(hc, stack_name, action=None, poll_period=5, marker=None, if action: stop_status = ('%s_FAILED' % action, '%s_COMPLETE' % action) - stop_check = lambda a: a in stop_status + stop_check = lambda a: a in stop_status # noqa: E731 else: - stop_check = lambda a: a.endswith('_COMPLETE') or a.endswith('_FAILED') + stop_check = lambda a: a.endswith('_COMPLETE') or a.endswith('_FAILED') # noqa E731 no_event_polls = 0 msg_template = _("\n Stack %(name)s %(status)s \n") diff --git a/heatclient/common/http.py b/heatclient/common/http.py index 1f86c24..3a85bc5 100644 --- a/heatclient/common/http.py +++ b/heatclient/common/http.py @@ -340,7 +340,7 @@ class SessionClient(adapter.LegacyJsonAdapter): raise exc.InvalidEndpoint(message=message) if (self.endpoint_override is not None and location.lower().startswith(self.endpoint_override.lower())): - return location[len(self.endpoint_override):] + return location[len(self.endpoint_override):] else: return location diff --git a/heatclient/common/template_format.py b/heatclient/common/template_format.py index fb275f6..6aaf1e0 100644 --- a/heatclient/common/template_format.py +++ b/heatclient/common/template_format.py @@ -39,6 +39,8 @@ def _construct_yaml_str(self, node): # Override the default string handling function # to always return unicode objects return self.construct_scalar(node) + + yaml_loader.add_constructor(u'tag:yaml.org,2002:str', _construct_yaml_str) # Unquoted dates like 2013-05-23 in yaml files get loaded as objects of type # datetime.data which causes problems in API layer when being processed by diff --git a/heatclient/common/utils.py b/heatclient/common/utils.py index ae32514..cb2cb88 100644 --- a/heatclient/common/utils.py +++ b/heatclient/common/utils.py @@ -377,8 +377,8 @@ def format_parameter_file(param_files, template_file=None, param_file = {} for key, value in params.items(): - param_file[key] = resolve_param_get_file(value, - template_base_url) + param_file[key] = resolve_param_get_file(value, + template_base_url) return param_file diff --git a/heatclient/shell.py b/heatclient/shell.py index b36c29f..b527274 100644 --- a/heatclient/shell.py +++ b/heatclient/shell.py @@ -615,5 +615,6 @@ def main(args=None): print(encodeutils.safe_encode(six.text_type(e)), file=sys.stderr) sys.exit(1) + if __name__ == "__main__": main() diff --git a/heatclient/tests/unit/test_deployment_utils.py b/heatclient/tests/unit/test_deployment_utils.py index 2f9c637..1167a76 100644 --- a/heatclient/tests/unit/test_deployment_utils.py +++ b/heatclient/tests/unit/test_deployment_utils.py @@ -291,9 +291,9 @@ class TempURLSignalTest(testtools.TestCase): '[a-f0-9]{3}-[a-f0-9]{12}') url = deployment_utils.create_temp_url(swift_client, 'bar', 60) self.assertFalse(swift_client.post_account.called) - regexp = ("http://fake-host.com:8080/v1/AUTH_demo/bar-%s" - "/%s\?temp_url_sig=[0-9a-f]{40}&" - "temp_url_expires=[0-9]{10}" % (uuid_pattern, uuid_pattern)) + regexp = (r"http://fake-host.com:8080/v1/AUTH_demo/bar-%s" + r"/%s\?temp_url_sig=[0-9a-f]{40}&" + r"temp_url_expires=[0-9]{10}" % (uuid_pattern, uuid_pattern)) self.assertThat(url, matchers.MatchesRegex(regexp)) timeout = int(url.split('=')[-1]) diff --git a/heatclient/tests/unit/test_shell.py b/heatclient/tests/unit/test_shell.py index fcb019c..0c8b272 100644 --- a/heatclient/tests/unit/test_shell.py +++ b/heatclient/tests/unit/test_shell.py @@ -557,7 +557,7 @@ class ShellTestNoMox(ShellTestNoMoxBase): template_file = os.path.join(TEST_VAR_DIR, 'minimal.template') self.shell_error('stack-create -f %s stack' % template_file, - 'The Parameter \(key_name\) was not provided.', + r'The Parameter \(key_name\) was not provided.', exception=exc.HTTPBadRequest) def test_event_list(self): @@ -2437,7 +2437,7 @@ class ShellTestUserPass(ShellBase): '{', '"output_key": "output2"', '"description": "test output 2"', - '"output_value": \[', + r'"output_value": \[', '"output"', '"value"', '"2"', diff --git a/heatclient/v1/shell.py b/heatclient/v1/shell.py index dad0568..04ebf44 100644 --- a/heatclient/v1/shell.py +++ b/heatclient/v1/shell.py @@ -728,7 +728,7 @@ def do_output_list(hc, args): utils.print_list(outputs['outputs'], fields, formatters=formatters) -@utils.arg('id', metavar='', +@utils.arg('id', metavar='', # noqa: C901 help=_('Name or ID of stack to query.')) @utils.arg('output', metavar='', nargs='?', default=None, help=_('Name of an output to display.')) -- cgit v1.2.1