From 787a6ac607384312767b599d85a680a01a7fad47 Mon Sep 17 00:00:00 2001 From: Andreas Jaeger Date: Mon, 30 Mar 2020 08:14:51 +0200 Subject: [PATCH] Update hacking for Python3 The repo is Python 3 now, so update hacking to version 2.0 which supports Python 3. Fix problems found. Update local hacking checks for new flake8. Change-Id: I5cb9b15a3391bf32bb6e43958f8f6ffbcd6bcf07 --- muranoclient/__init__.py | 1 + muranoclient/common/utils.py | 3 +++ muranoclient/common/yaqlexpression.py | 3 ++- muranoclient/common/yaqlexpression_legacy.py | 2 +- muranoclient/glance/artifacts.py | 2 +- muranoclient/tests/unit/test_shell.py | 12 ++++++------ test-requirements.txt | 2 +- 7 files changed, 15 insertions(+), 10 deletions(-) diff --git a/muranoclient/__init__.py b/muranoclient/__init__.py index 15fac738..083d7b8f 100644 --- a/muranoclient/__init__.py +++ b/muranoclient/__init__.py @@ -22,6 +22,7 @@ _ROOT = os.path.abspath(os.path.dirname(__file__)) def get_resource(path): return os.path.join(_ROOT, 'data', path) + version_info = pbr.version.VersionInfo('python-muranoclient') try: diff --git a/muranoclient/common/utils.py b/muranoclient/common/utils.py index 15d51c5c..670abc07 100644 --- a/muranoclient/common/utils.py +++ b/muranoclient/common/utils.py @@ -743,6 +743,7 @@ class DummyYaqlYamlLoader(yaml.SafeLoader): """Constructor that treats !yaql as string.""" pass + DummyYaqlYamlLoader.add_constructor( u'!yaql', DummyYaqlYamlLoader.yaml_constructors[u'tag:yaml.org,2002:str']) @@ -750,6 +751,7 @@ DummyYaqlYamlLoader.add_constructor( class YaqlYamlLoader(yaml.SafeLoader): pass + # workaround for PyYAML bug: http://pyyaml.org/ticket/221 resolvers = {} for k, v in yaml.SafeLoader.yaml_implicit_resolvers.items(): @@ -761,6 +763,7 @@ def yaql_constructor(loader, node): value = loader.construct_scalar(node) return YaqlExpression(value) + YaqlYamlLoader.add_constructor(u'!yaql', yaql_constructor) YaqlYamlLoader.add_implicit_resolver(u'!yaql', YaqlExpression, None) diff --git a/muranoclient/common/yaqlexpression.py b/muranoclient/common/yaqlexpression.py index c9b19e8b..d1675070 100644 --- a/muranoclient/common/yaqlexpression.py +++ b/muranoclient/common/yaqlexpression.py @@ -25,6 +25,7 @@ def _set_up_yaql(): } return yaql.YaqlFactory().create(options=legacy_engine_options) + YAQL = _set_up_yaql() @@ -46,7 +47,7 @@ class YaqlExpression(object): def match(expr): if not isinstance(expr, six.string_types): return False - if re.match('^[\s\w\d.:]*$', expr): + if re.match(r'^[\s\w\d.:]*$', expr): return False try: YAQL(expr) diff --git a/muranoclient/common/yaqlexpression_legacy.py b/muranoclient/common/yaqlexpression_legacy.py index d297d26d..47af4235 100644 --- a/muranoclient/common/yaqlexpression_legacy.py +++ b/muranoclient/common/yaqlexpression_legacy.py @@ -35,7 +35,7 @@ class YaqlExpression(object): def match(expr): if not isinstance(expr, six.string_types): return False - if re.match('^[\s\w\d.:]*$', expr): + if re.match(r'^[\s\w\d.:]*$', expr): return False try: yaql.parse(expr) diff --git a/muranoclient/glance/artifacts.py b/muranoclient/glance/artifacts.py index 8b7ecb03..f16049e0 100644 --- a/muranoclient/glance/artifacts.py +++ b/muranoclient/glance/artifacts.py @@ -97,7 +97,7 @@ class Controller(object): :param artifact_id: ID of the artifact to modify. :param remove_props: List of property names to remove - :param \*\*kwargs: Artifact attribute names and their new values. + :param **kwargs: Artifact attribute names and their new values. """ type_name, type_version = self._check_type_params(type_name, type_version) diff --git a/muranoclient/tests/unit/test_shell.py b/muranoclient/tests/unit/test_shell.py index fdba7a84..08a54140 100644 --- a/muranoclient/tests/unit/test_shell.py +++ b/muranoclient/tests/unit/test_shell.py @@ -153,9 +153,9 @@ class ShellCommandTest(ShellTest): def test_help(self): required = [ - '.*?^usage: murano', - '.*?^\s+package-create\s+Create an application package.', - '.*?^See "murano help COMMAND" for help on a specific command', + r'.*?^usage: murano', + r'.*?^\s+package-create\s+Create an application package.', + r'.*?^See "murano help COMMAND" for help on a specific command', ] stdout, stderr = self.shell('help') for r in required: @@ -174,9 +174,9 @@ class ShellCommandTest(ShellTest): def test_help_no_options(self): required = [ - '.*?^usage: murano', - '.*?^\s+package-create\s+Create an application package', - '.*?^See "murano help COMMAND" for help on a specific command', + r'.*?^usage: murano', + r'.*?^\s+package-create\s+Create an application package', + r'.*?^See "murano help COMMAND" for help on a specific command', ] stdout, stderr = self.shell('') for r in required: diff --git a/test-requirements.txt b/test-requirements.txt index 4d1fd051..29fd1108 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,7 +1,7 @@ # The order of packages is significant, because pip processes them in the order # of appearance. Changing the order has an impact on the overall integration # process, which may cause wedges in the gate later. -hacking!=0.13.0,<0.14,>=0.12.0 # Apache-2.0 +hacking>=2.0,<2.1.0 # Apache-2.0 coverage!=4.4,>=4.0 # Apache-2.0 fixtures>=3.0.0 # Apache-2.0/BSD