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 to work with new flake8 version. Change-Id: Id5d224358b44fd7ab4bd3d08f1db6b6faf54042f
This commit is contained in:
parent
a725f64412
commit
e66d3e7599
@ -112,7 +112,7 @@ class ParsableErrorMiddleware(object):
|
||||
if error is not None and 'faultstring' in fault:
|
||||
fault['faultstring'] = i18n.translate(error,
|
||||
user_locale)
|
||||
except ValueError as err:
|
||||
except ValueError:
|
||||
fault = app_data
|
||||
body = jsonutils.dumps({'error_message': fault})
|
||||
if six.PY3:
|
||||
|
@ -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)
|
||||
|
@ -102,7 +102,7 @@ class MTable(object):
|
||||
filters = filter.split('AND')
|
||||
for f in filters:
|
||||
# Extract filter name and its arguments
|
||||
g = re.search("(.*)\((.*),?\)", f)
|
||||
g = re.search(r"(.*)\((.*),?\)", f)
|
||||
fname = g.group(1).strip()
|
||||
fargs = [s.strip().replace('\'', '')
|
||||
for s in g.group(2).split(',')]
|
||||
|
@ -160,7 +160,7 @@ def make_query(trait_query=None, **kwargs):
|
||||
if key == 'trait_type':
|
||||
q.append("ColumnPrefixFilter('%s')" % value)
|
||||
elif key == 'event_id':
|
||||
q.append("RowFilter ( = , 'regexstring:\d*:%s')" % value)
|
||||
q.append(r"RowFilter ( = , 'regexstring:\d*:%s')" % value)
|
||||
else:
|
||||
q.append("SingleColumnValueFilter "
|
||||
"('f', '%s', =, 'binary:%s', true, true)" %
|
||||
|
@ -82,6 +82,7 @@ def run_migrations_online():
|
||||
with context.begin_transaction():
|
||||
context.run_migrations()
|
||||
|
||||
|
||||
if context.is_offline_mode():
|
||||
run_migrations_offline()
|
||||
else:
|
||||
|
@ -18,8 +18,8 @@ from panko.tests.functional.api import v2 as tests_api
|
||||
class TestCapabilitiesController(tests_api.FunctionalTest):
|
||||
|
||||
def setUp(self):
|
||||
super(TestCapabilitiesController, self).setUp()
|
||||
self.url = '/capabilities'
|
||||
super(TestCapabilitiesController, self).setUp()
|
||||
self.url = '/capabilities'
|
||||
|
||||
def test_capabilities(self):
|
||||
data = self.get_json(self.url)
|
||||
|
13
tox.ini
13
tox.ini
@ -34,7 +34,7 @@ commands =
|
||||
coverage report
|
||||
|
||||
[testenv:pep8]
|
||||
deps = hacking<0.13,>=0.12.0
|
||||
deps = hacking<3.1.0,>=3.0.0
|
||||
doc8
|
||||
commands = flake8
|
||||
doc8 {posargs}
|
||||
@ -72,11 +72,18 @@ ignore = D000
|
||||
ignore-path = .venv,.git,.tox,*panko/locale*,*lib/python*,panko.egg*,doc/build,doc/source/api,releasenotes/*
|
||||
|
||||
[flake8]
|
||||
ignore =
|
||||
# W503 line break before binary operator
|
||||
# W504 line break after binary operator
|
||||
ignore = W503,W504
|
||||
exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build
|
||||
show-source = True
|
||||
|
||||
[hacking]
|
||||
import_exceptions =
|
||||
panko.i18n
|
||||
local-check-factory = panko.hacking.checks.factory
|
||||
|
||||
[flake8:local-plugins]
|
||||
extension =
|
||||
C301 = checks:no_log_warn
|
||||
C302 = checks:no_os_popen
|
||||
paths = ./panko/hacking
|
||||
|
Loading…
Reference in New Issue
Block a user