Update hacking for Python3

The repo is Python 3 now, so update hacking to version 3.0 which
supports Python 3.

Fix problems found.

Update local hacking checks for new flake8.

Change-Id: I7073a478d38fb46619e7a300808e9449403e704d
This commit is contained in:
Andreas Jaeger 2020-03-30 08:26:47 +02:00 committed by Andreas Jaeger
parent a9956206d5
commit c80e23edfd
13 changed files with 39 additions and 36 deletions

View File

@ -37,6 +37,6 @@ class WorkflowManagementForm(object):
'Just A-Z, a-z, 0-9, dash and underline'
' are allowed',
'label': 'Application Name',
'regexpValidator': '^[-\w]+$',
'regexpValidator': r'^[-\w]+$',
'initial': fqn.split('.')[-1]
}

View File

@ -139,7 +139,7 @@ def switch(request, environment_id,
def get_next_quick_environment_name(request):
quick_env_prefix = 'quick-env-'
quick_env_re = re.compile('^' + quick_env_prefix + '([\d]+)$')
quick_env_re = re.compile(r'^' + quick_env_prefix + r'([\d]+)$')
def parse_number(env):
match = re.match(quick_env_re, env.name)

View File

@ -26,6 +26,7 @@ class AppCatalog(horizon.Dashboard):
default_panel = "environments"
supports_tenants = True
try:
horizon.base.Horizon.registered('app-catalog')
except horizon.base.NotRegistered:

View File

@ -254,8 +254,8 @@ class CharField(forms.CharField, CustomPropertiesField):
class PasswordField(CharField):
special_characters = '!@#$%^&*()_+|\/.,~?><:{}-'
password_re = re.compile('^.*(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[%s]).*$'
special_characters = '!@#$%^&*()_+|\\/.,~?><:{}-'
password_re = re.compile(r'^.*(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[%s]).*$'
% special_characters)
has_clone = False
original = True

View File

@ -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, str):
return False
if re.match('^[\s\w\d.:]*$', expr):
if re.match(r'^[\s\w\d.:]*$', expr):
return False
try:
YAQL(expr)

View File

@ -44,8 +44,8 @@ def get_status_messages_for_service(request, service_id, environment_id):
environment_id, deployment.id, service_id)
for report in reports:
result += utils.adjust_datestr(request, report.created) + ' - ' + \
report.text + '\n'
result += (utils.adjust_datestr(request, report.created) +
' - ' + report.text + '\n')
return result

View File

@ -108,26 +108,26 @@ class OverviewTab(tabs.Tab):
# after it would be possible
if hasattr(service_data,
'instance') and service_data['instance'] is not None:
instance, stack = get_instance_and_stack(
service_data['instance'], request)
if instance:
detail_info['Instance'] = instance
if stack:
detail_info['Stack'] = stack
instance, stack = get_instance_and_stack(
service_data['instance'], request)
if instance:
detail_info['Instance'] = instance
if stack:
detail_info['Stack'] = stack
if hasattr(service_data,
'instances') and service_data['instances'] is not None:
instances_for_template = []
stacks_for_template = []
for instance in service_data['instances']:
instance, stack = get_instance_and_stack(instance, request)
instances_for_template.append(instance)
if stack:
stacks_for_template.append(stack)
if instances_for_template:
detail_info['Instances'] = instances_for_template
if stacks_for_template:
detail_info['Stacks'] = stacks_for_template
instances_for_template = []
stacks_for_template = []
for instance in service_data['instances']:
instance, stack = get_instance_and_stack(instance, request)
instances_for_template.append(instance)
if stack:
stacks_for_template.append(stack)
if instances_for_template:
detail_info['Instances'] = instances_for_template
if stacks_for_template:
detail_info['Stacks'] = stacks_for_template
return {'service': detail_info}

View File

@ -48,6 +48,7 @@ def register_config(config, config_group, config_opts):
config.register_group(config_group)
config.register_opts(config_opts, config_group)
path = os.path.join(os.path.dirname(__file__), "config.conf")
if os.path.exists(path):

View File

@ -37,13 +37,13 @@ class TestLicenseTab(helpers.APITestCase):
app.id = 1
group = tabs.ApplicationTabs(self.request, application=app)
l = group.get_tabs()[2]
li = group.get_tabs()[2]
# Should return the license description
l._get_license()
li._get_license()
self.assertEqual(
'Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
l.app.license)
li.app.license)
@mock.patch('muranodashboard.catalog.tabs.services')
def test_no_license(self, mock_services):
@ -59,11 +59,11 @@ class TestLicenseTab(helpers.APITestCase):
app.id = 1
group = tabs.ApplicationTabs(self.request, application=app)
l = group.get_tabs()[2]
li = group.get_tabs()[2]
# Should return the license description
l._get_license()
self.assertEqual('', l.app.license)
li._get_license()
self.assertEqual('', li.app.license)
class TestRequirementsTab(helpers.APITestCase):

View File

@ -49,7 +49,7 @@ class TestNet(unittest.TestCase):
foo_mock_network, bar_mock_network
]
test_filter = '^foo\-[\w]+'
test_filter = r'^foo\-[\w]+'
result = net.get_available_networks(self.mock_request,
filter=test_filter,
murano_networks='include')
@ -82,7 +82,7 @@ class TestNet(unittest.TestCase):
foo_mock_network, bar_mock_network
]
test_filter = '^[\w]+\-[\w]+'
test_filter = r'^[\w]+\-[\w]+'
result = net.get_available_networks(self.mock_request,
filter=test_filter,
murano_networks='include')

View File

@ -72,8 +72,8 @@ class TestImportPackageForm(helpers.APITestCase):
'package': mock_package
}
expected_error_msg = 'It is forbidden to upload files larger than {0} '\
'MB.'.format(consts.MAX_FILE_SIZE_MB)
expected_error_msg = 'It is forbidden to upload files larger than '\
'{0} MB.'.format(consts.MAX_FILE_SIZE_MB)
with self.assertRaisesRegex(django_forms.ValidationError,
expected_error_msg):
self.import_pkg_form.clean_package()

View File

@ -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>=3.0,<4.0.0 # Apache-2.0
coverage!=4.4,>=4.0 # Apache-2.0
oslo.config>=5.2.0 # Apache-2.0

View File

@ -63,7 +63,7 @@ commands =
[flake8]
# H202: assertRaises Exception too broad
ignore = H202
ignore = H202,W504
show-source = true
builtins = _
exclude=build,.git,.tox,dist,doc,*lib/python*,*egg,tools,horizon,settings.py,*/local/*,functional_tests,node_modules