[flake8] Enable extra, optional hacking checks

Update test-requirements.txt to use latest version of:
    * hacking

Enable the following off-by-default checks:
    * [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.
    * [H210] Require ‘autospec’, ‘spec’, or ‘spec_set’ in
             mock.patch/mock.patch.object calls
    * [H904] Delay string interpolations at logging calls.

Made minimal code changes to comply with changes.

Change-Id: I3559ead76b5476650d7193e7023d349175234922
This commit is contained in:
Felipe Monteiro 2017-09-21 00:46:26 +01:00
parent 279418673a
commit 8715fe3e02
4 changed files with 11 additions and 7 deletions

View File

@ -32,7 +32,7 @@ class TestApi(test_base.DeckhandTestCase):
resource_name = resource.__name__.split('.')[-1]
resource_obj = mock.patch.object(
resource, '%sResource' % resource_name.title().replace(
'_', '')).start()
'_', ''), autospec=True).start()
setattr(self, '%s_resource' % resource_name, resource_obj)
@mock.patch.object(api, 'db_api', autospec=True)

View File

@ -3,7 +3,7 @@
# process, which may cause wedges in the gate later.
# Hacking already pins down pep8, pyflakes and flake8
hacking!=0.13.0,<0.14,>=0.12.0 # Apache-2.0
hacking>=1.0.0 # Apache-2.0
falcon>=1.0.0 # Apache-2.0
pbr!=2.1.0,>=2.0.0 # Apache-2.0

View File

@ -3,7 +3,7 @@
# process, which may cause wedges in the gate later.
# Hacking already pins down pep8, pyflakes and flake8
hacking!=0.13.0,<0.14,>=0.12.0 # Apache-2.0
hacking>=1.0.0 # Apache-2.0
coverage!=4.4,>=4.0 # Apache-2.0
fixtures>=3.0.0 # Apache-2.0/BSD

12
tox.ini
View File

@ -59,8 +59,12 @@ commands = oslo-config-generator --config-file=etc/deckhand/config-generator.con
commands = flake8 {posargs}
[flake8]
# D100-104 deal with docstrings in public functions
# D205, D400, D401 deal with docstring formatting
enable-extensions = H106,H203,H904
# [H106] Dont 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.
# [H210] Require autospec, spec, or spec_set in mock.patch/mock.patch.object calls
# [H904] Delay string interpolations at logging calls.
enable-extensions = H106,H203,H204,H205,H210,H904
ignore = E121,E122,E123,E124,E125,E126,E127,E128,E129,E131,E251,H405
exclude = .venv,.git,.tox,dist,*lib/python*,*egg,build,tools/xenserver*,releasenotes
exclude = .venv,.git,.tox,dist,*lib/python*,*egg,build,releasenotes