Update flake8 style enforcement

Added enforcement of H106, H203, H204 and H205 extensions to
match neutron repo, fixing a few failures in the process.

Also updated to support hacking 1.1.0, bringing in flake8
2.6.2 and pycodestyle 2.4.0 in the process.  This ensures
future python3 compatibility and a bit better code styling.

Change-Id: Ibd9cff863eaff940755ccb9c20f39e29e2001cde
This commit is contained in:
Brian Haley 2019-06-26 16:30:35 -04:00
parent c26573f847
commit bf810d24ed
5 changed files with 13 additions and 9 deletions

View File

@ -13,12 +13,12 @@ eventlet==0.18.2
extras==1.0.0
fasteners==0.7.0
fixtures==3.0.0
flake8==2.5.5
flake8==2.6.2
flake8-import-order==0.12
future==0.16.0
futurist==1.2.0
greenlet==0.4.10
hacking==0.12.0
hacking==1.1.0
imagesize==0.7.1
iso8601==0.1.11
Jinja2==2.10
@ -61,7 +61,7 @@ pep8==1.5.7
pika==0.10.0
pika-pool==0.1.3
prettytable==0.7.2
pycodestyle==2.3.1
pycodestyle==2.4.0
pyflakes==0.8.1
Pygments==2.2.0
pyinotify==0.9.6

View File

@ -158,7 +158,7 @@ class TestDeadLockDecorator(_base.BaseTestCase):
if exc_to_raise == db_exc.DBDeadlock:
self.assertEqual(True, (fake_timer.counter <= sum(worst_case)))
else:
self.assertTrue(sum(worst_case) >= fake_timer.counter)
self.assertGreaterEqual(sum(worst_case), fake_timer.counter)
def test_all_deadlock_time_elapsed(self):
self._test_retry_time_cost(db_exc.DBDeadlock)

View File

@ -38,13 +38,13 @@ class HackingTestCase(base.BaseTestCase):
return check_fns
def test_factory(self):
self.assertTrue(len(self._get_factory_checks(checks.factory)) > 0)
self.assertGreater(len(self._get_factory_checks(checks.factory)), 0)
def test_neutron_lib_factory(self):
lib_checks = self._get_factory_checks(checks._neutron_lib_factory)
other_checks = self._get_factory_checks(checks.factory)
self.assertTrue(len(lib_checks) > 0)
self.assertGreater(len(lib_checks), 0)
if other_checks:
for other_check in other_checks:

View File

@ -116,5 +116,5 @@ class TestListPackageModules(base.BaseTestCase):
def test_list_package_modules(self):
# mainly just to ensure we can import modules for both PY2/PY3
self.assertTrue(
len(runtime.list_package_modules('neutron_lib.exceptions')) > 3)
self.assertGreater(
len(runtime.list_package_modules('neutron_lib.exceptions')), 3)

View File

@ -91,8 +91,12 @@ commands =
{toxinidir}/tools/api_report.sh
[flake8]
# H106: Don't put vim configuration in source files
# H203: Use assertIs(Not)None to check for None
# H204: Use assert(Not)Equal to check for equality
# H205: Use assert(Greater|Less)(Equal) for comparison
# H904: Delay string interpolations at logging calls
enable-extensions=H904
enable-extensions=H106,H203,H204,H205,H904
show-source = True
exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build,tools
import-order-style = pep8