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.

Remove hacking and friends from lower-constraints, they are not needed
to be installed at run-time.

Change-Id: Ia6af344ec8441dc98a0820176373dcff3a8c80d5
This commit is contained in:
Andreas Jaeger
2020-04-02 07:36:46 +02:00
parent 60a3f1f072
commit 1bb2aefec3
19 changed files with 65 additions and 62 deletions

View File

@@ -188,7 +188,7 @@ class CeilometerHelper(base.DataSourceBase):
item_value = None
if statistic:
item_value = statistic[-1]._info.get('aggregate').get(aggregate)
if meter_name is 'host_airflow':
if meter_name == 'host_airflow':
# Airflow from hardware.ipmi.node.airflow is reported as
# 1/10 th of actual CFM
item_value *= 10

View File

@@ -116,7 +116,7 @@ class GnocchiHelper(base.DataSourceBase):
# measure has structure [time, granularity, value]
return_value = statistics[-1][2]
if meter_name is 'host_airflow':
if meter_name == 'host_airflow':
# Airflow from hardware.ipmi.node.airflow is reported as
# 1/10 th of actual CFM
return_value *= 10

View File

@@ -72,7 +72,7 @@ class GrafanaHelper(base.DataSourceBase):
# Very basic url parsing
parse = urlparse.urlparse(self._base_url)
if parse.scheme is '' or parse.netloc is '' or parse.path is '':
if parse.scheme == '' or parse.netloc == '' or parse.path == '':
LOG.critical("GrafanaHelper url not properly configured, "
"check base_url and project_id")
return

View File

@@ -112,10 +112,10 @@ class DataSourceManager(object):
datasource is attempted.
"""
if not self.datasources or len(self.datasources) is 0:
if not self.datasources or len(self.datasources) == 0:
raise exception.NoDatasourceAvailable
if not metrics or len(metrics) is 0:
if not metrics or len(metrics) == 0:
LOG.critical("Can not retrieve datasource without specifying "
"list of required metrics.")
raise exception.InvalidParameter(parameter='metrics',
@@ -125,11 +125,11 @@ class DataSourceManager(object):
no_metric = False
for metric in metrics:
if (metric not in self.metric_map[datasource] or
self.metric_map[datasource].get(metric) is None):
no_metric = True
LOG.warning("Datasource: {0} could not be used due to "
"metric: {1}".format(datasource, metric))
break
self.metric_map[datasource].get(metric) is None):
no_metric = True
LOG.warning("Datasource: {0} could not be used due to "
"metric: {1}".format(datasource, metric))
break
if not no_metric:
# Try to use a specific datasource but attempt additional
# datasources upon exceptions (if config has more datasources)

View File

@@ -401,7 +401,7 @@ class BasicConsolidation(base.ServerConsolidationBaseStrategy):
self._pre_execute()
# backwards compatibility for node parameter.
if self.aggregation_method['node'] is not '':
if self.aggregation_method['node'] != '':
LOG.warning('Parameter node has been renamed to compute_node and '
'will be removed in next release.')
self.aggregation_method['compute_node'] = \

View File

@@ -514,7 +514,7 @@ class WorkloadStabilization(base.WorkloadStabilizationBaseStrategy):
self.aggregation_method['node']
# backwards compatibility for node parameter with period.
if self.periods['node'] is not 0:
if self.periods['node'] != 0:
LOG.warning('Parameter node has been renamed to compute_node and '
'will be removed in next release.')
self.periods['compute_node'] = self.periods['node']