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
This commit is contained in:
Andreas Jaeger 2020-03-30 08:14:51 +02:00
parent 242fead1ac
commit 787a6ac607
7 changed files with 15 additions and 10 deletions

View File

@ -22,6 +22,7 @@ _ROOT = os.path.abspath(os.path.dirname(__file__))
def get_resource(path): def get_resource(path):
return os.path.join(_ROOT, 'data', path) return os.path.join(_ROOT, 'data', path)
version_info = pbr.version.VersionInfo('python-muranoclient') version_info = pbr.version.VersionInfo('python-muranoclient')
try: try:

View File

@ -743,6 +743,7 @@ class DummyYaqlYamlLoader(yaml.SafeLoader):
"""Constructor that treats !yaql as string.""" """Constructor that treats !yaql as string."""
pass pass
DummyYaqlYamlLoader.add_constructor( DummyYaqlYamlLoader.add_constructor(
u'!yaql', DummyYaqlYamlLoader.yaml_constructors[u'tag:yaml.org,2002:str']) u'!yaql', DummyYaqlYamlLoader.yaml_constructors[u'tag:yaml.org,2002:str'])
@ -750,6 +751,7 @@ DummyYaqlYamlLoader.add_constructor(
class YaqlYamlLoader(yaml.SafeLoader): class YaqlYamlLoader(yaml.SafeLoader):
pass pass
# workaround for PyYAML bug: http://pyyaml.org/ticket/221 # workaround for PyYAML bug: http://pyyaml.org/ticket/221
resolvers = {} resolvers = {}
for k, v in yaml.SafeLoader.yaml_implicit_resolvers.items(): for k, v in yaml.SafeLoader.yaml_implicit_resolvers.items():
@ -761,6 +763,7 @@ def yaql_constructor(loader, node):
value = loader.construct_scalar(node) value = loader.construct_scalar(node)
return YaqlExpression(value) return YaqlExpression(value)
YaqlYamlLoader.add_constructor(u'!yaql', yaql_constructor) YaqlYamlLoader.add_constructor(u'!yaql', yaql_constructor)
YaqlYamlLoader.add_implicit_resolver(u'!yaql', YaqlExpression, None) YaqlYamlLoader.add_implicit_resolver(u'!yaql', YaqlExpression, None)

View File

@ -25,6 +25,7 @@ def _set_up_yaql():
} }
return yaql.YaqlFactory().create(options=legacy_engine_options) return yaql.YaqlFactory().create(options=legacy_engine_options)
YAQL = _set_up_yaql() YAQL = _set_up_yaql()
@ -46,7 +47,7 @@ class YaqlExpression(object):
def match(expr): def match(expr):
if not isinstance(expr, six.string_types): if not isinstance(expr, six.string_types):
return False return False
if re.match('^[\s\w\d.:]*$', expr): if re.match(r'^[\s\w\d.:]*$', expr):
return False return False
try: try:
YAQL(expr) YAQL(expr)

View File

@ -35,7 +35,7 @@ class YaqlExpression(object):
def match(expr): def match(expr):
if not isinstance(expr, six.string_types): if not isinstance(expr, six.string_types):
return False return False
if re.match('^[\s\w\d.:]*$', expr): if re.match(r'^[\s\w\d.:]*$', expr):
return False return False
try: try:
yaql.parse(expr) yaql.parse(expr)

View File

@ -97,7 +97,7 @@ class Controller(object):
:param artifact_id: ID of the artifact to modify. :param artifact_id: ID of the artifact to modify.
:param remove_props: List of property names to remove :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_name, type_version = self._check_type_params(type_name,
type_version) type_version)

View File

@ -153,9 +153,9 @@ class ShellCommandTest(ShellTest):
def test_help(self): def test_help(self):
required = [ required = [
'.*?^usage: murano', r'.*?^usage: murano',
'.*?^\s+package-create\s+Create an application package.', r'.*?^\s+package-create\s+Create an application package.',
'.*?^See "murano help COMMAND" for help on a specific command', r'.*?^See "murano help COMMAND" for help on a specific command',
] ]
stdout, stderr = self.shell('help') stdout, stderr = self.shell('help')
for r in required: for r in required:
@ -174,9 +174,9 @@ class ShellCommandTest(ShellTest):
def test_help_no_options(self): def test_help_no_options(self):
required = [ required = [
'.*?^usage: murano', r'.*?^usage: murano',
'.*?^\s+package-create\s+Create an application package', r'.*?^\s+package-create\s+Create an application package',
'.*?^See "murano help COMMAND" for help on a specific command', r'.*?^See "murano help COMMAND" for help on a specific command',
] ]
stdout, stderr = self.shell('') stdout, stderr = self.shell('')
for r in required: for r in required:

View File

@ -1,7 +1,7 @@
# The order of packages is significant, because pip processes them in the order # 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 # of appearance. Changing the order has an impact on the overall integration
# process, which may cause wedges in the gate later. # 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 coverage!=4.4,>=4.0 # Apache-2.0
fixtures>=3.0.0 # Apache-2.0/BSD fixtures>=3.0.0 # Apache-2.0/BSD