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: I129bc38e6663836e12610dd50a20c74dbc79891c
This commit is contained in:
parent
56012eaa5c
commit
1a6a003242
|
@ -187,7 +187,7 @@ class InstanceDiscovery(plugin_base.DiscoveryBase):
|
|||
image_xml = metadata_xml.find("./root[@type='image']")
|
||||
image = ({'id': image_xml.attrib['uuid']}
|
||||
if image_xml is not None else None)
|
||||
except AttributeError as e:
|
||||
except AttributeError:
|
||||
LOG.error(
|
||||
"Fail to get domain uuid %s metadata: "
|
||||
"metadata was missing expected attributes",
|
||||
|
|
|
@ -13,12 +13,7 @@
|
|||
# under the License.
|
||||
|
||||
import collections
|
||||
import six
|
||||
|
||||
if six.PY2:
|
||||
from monotonic import monotonic as now
|
||||
else:
|
||||
from time import monotonic as now
|
||||
from time import monotonic as now
|
||||
|
||||
from oslo_log import log
|
||||
from oslo_utils import timeutils
|
||||
|
|
|
@ -26,7 +26,10 @@ Guidelines for writing new hacking checks
|
|||
|
||||
"""
|
||||
|
||||
from hacking import core
|
||||
|
||||
|
||||
@core.flake8ext
|
||||
def no_log_warn(logical_line):
|
||||
"""Disallow 'LOG.warn('
|
||||
|
||||
|
@ -38,6 +41,7 @@ def no_log_warn(logical_line):
|
|||
yield(0, 'C301 Use LOG.warning() rather than LOG.warn()')
|
||||
|
||||
|
||||
@core.flake8ext
|
||||
def no_os_popen(logical_line):
|
||||
"""Disallow 'os.popen('
|
||||
|
||||
|
@ -50,8 +54,3 @@ def no_os_popen(logical_line):
|
|||
if 'os.popen(' in logical_line:
|
||||
yield(0, 'C302 Deprecated library function os.popen(). '
|
||||
'Replace it using subprocess module. ')
|
||||
|
||||
|
||||
def factory(register):
|
||||
register(no_log_warn)
|
||||
register(no_os_popen)
|
||||
|
|
|
@ -119,7 +119,7 @@ class SensorNotification(endpoint.SampleEndpoint):
|
|||
|
||||
try:
|
||||
sensor_reading = info['payload']['Sensor Reading']
|
||||
except KeyError as exc:
|
||||
except KeyError:
|
||||
raise InvalidSensorData(
|
||||
"missing 'Sensor Reading' in payload"
|
||||
)
|
||||
|
|
|
@ -414,10 +414,10 @@ class OpenDayLightDriver(driver.Driver):
|
|||
val_iter, key_func = None, None
|
||||
if isinstance(value, dict):
|
||||
val_iter = six.iteritems(value)
|
||||
key_func = lambda k: key_base + '.' + k if key_base else k
|
||||
key_func = lambda k: key_base + '.' + k if key_base else k # noqa
|
||||
elif isinstance(value, (tuple, list)):
|
||||
val_iter = enumerate(value)
|
||||
key_func = lambda k: key_base + '[%d]' % k
|
||||
key_func = lambda k: key_base + '[%d]' % k # noqa: E731
|
||||
|
||||
if val_iter:
|
||||
for k, v in val_iter:
|
||||
|
|
|
@ -345,7 +345,7 @@ class PollsterDefinition(object):
|
|||
|
||||
class PollsterDefinitions(object):
|
||||
|
||||
POLLSTER_VALID_NAMES_REGEXP = "^([\w-]+)(\.[\w-]+)*(\.{[\w-]+})?$"
|
||||
POLLSTER_VALID_NAMES_REGEXP = r"^([\w-]+)(\.[\w-]+)*(\.{[\w-]+})?$"
|
||||
|
||||
standard_definitions = [
|
||||
PollsterDefinition(name='name', required=True,
|
||||
|
@ -416,10 +416,10 @@ class PollsterDefinitions(object):
|
|||
|
||||
class MultiMetricPollsterDefinitions(PollsterDefinitions):
|
||||
|
||||
MULTI_METRIC_POLLSTER_NAME_REGEXP = ".*(\.{(\w+)})$"
|
||||
MULTI_METRIC_POLLSTER_NAME_REGEXP = r".*(\.{(\w+)})$"
|
||||
pattern_pollster_name = re.compile(
|
||||
MULTI_METRIC_POLLSTER_NAME_REGEXP)
|
||||
MULTI_METRIC_POLLSTER_VALUE_ATTRIBUTE_REGEXP = "^(\[(\w+)\])((\.\w+)+)$"
|
||||
MULTI_METRIC_POLLSTER_VALUE_ATTRIBUTE_REGEXP = r"^(\[(\w+)\])((\.\w+)+)$"
|
||||
pattern_pollster_value_attribute = re.compile(
|
||||
MULTI_METRIC_POLLSTER_VALUE_ATTRIBUTE_REGEXP)
|
||||
|
||||
|
|
|
@ -132,7 +132,7 @@ class PollingTask(object):
|
|||
|
||||
# we relate the static resources and per-source discovery to
|
||||
# each combination of pollster and matching source
|
||||
resource_factory = lambda: Resources(agent_manager)
|
||||
resource_factory = lambda: Resources(agent_manager) # noqa: E731
|
||||
self.resources = collections.defaultdict(resource_factory)
|
||||
|
||||
self._batch_size = self.manager.conf.polling.batch_size
|
||||
|
|
|
@ -100,7 +100,8 @@ class HttpPublisher(publisher.ConfigPublisherBase):
|
|||
password = parsed_url.password
|
||||
if username:
|
||||
self.client_auth = (username, password)
|
||||
netloc = parsed_url.netloc.replace(username+':'+password+'@', '')
|
||||
netloc = parsed_url.netloc.replace(username + ':' + password + '@',
|
||||
'')
|
||||
else:
|
||||
self.client_auth = None
|
||||
netloc = parsed_url.netloc
|
||||
|
|
14
tox.ini
14
tox.ini
|
@ -28,7 +28,7 @@ commands =
|
|||
coverage xml -o cover/coverage.xml
|
||||
|
||||
[testenv:pep8]
|
||||
deps = hacking<0.13,>=0.12
|
||||
deps = hacking>=3.0,<=3.1.0
|
||||
doc8
|
||||
commands =
|
||||
flake8
|
||||
|
@ -65,14 +65,22 @@ ignore = D000
|
|||
ignore-path = .venv,.git,.tox,*ceilometer/locale*,*lib/python*,ceilometer.egg*,doc/build,doc/source/api,releasenotes/*
|
||||
|
||||
[flake8]
|
||||
ignore =
|
||||
# E123 closing bracket does not match indentation of opening bracket's line
|
||||
# W503 line break before binary operator
|
||||
# W504 line break after binary operator
|
||||
ignore = E123,W503,W504
|
||||
exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build,install-guide
|
||||
show-source = True
|
||||
|
||||
[hacking]
|
||||
import_exceptions =
|
||||
ceilometer.i18n
|
||||
local-check-factory = ceilometer.hacking.checks.factory
|
||||
|
||||
[flake8:local-plugins]
|
||||
extension =
|
||||
C301 = checks:no_log_warn
|
||||
C302 = checks:no_os_popen
|
||||
paths = ./ceilometer/hacking
|
||||
|
||||
[testenv:lower-constraints]
|
||||
deps =
|
||||
|
|
Loading…
Reference in New Issue