From 8715fe3e022b7dcad5b220cb49fb1094b071bd58 Mon Sep 17 00:00:00 2001 From: Felipe Monteiro Date: Thu, 21 Sep 2017 00:46:26 +0100 Subject: [PATCH] [flake8] Enable extra, optional hacking checks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- deckhand/tests/unit/control/test_api.py | 2 +- requirements.txt | 2 +- test-requirements.txt | 2 +- tox.ini | 12 ++++++++---- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/deckhand/tests/unit/control/test_api.py b/deckhand/tests/unit/control/test_api.py index 3a324614..b13580ad 100644 --- a/deckhand/tests/unit/control/test_api.py +++ b/deckhand/tests/unit/control/test_api.py @@ -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) diff --git a/requirements.txt b/requirements.txt index 35370c70..02c6a8b2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -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 diff --git a/test-requirements.txt b/test-requirements.txt index 844a5861..44158b11 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -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 diff --git a/tox.ini b/tox.ini index db758db7..b00a689c 100644 --- a/tox.ini +++ b/tox.ini @@ -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] 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. +# [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