From d640718167eb9e9d17c97b64b636063f2b82ba1e Mon Sep 17 00:00:00 2001 From: Steven Dake Date: Wed, 27 Feb 2013 15:23:48 -0700 Subject: [PATCH] Gate on certain pyflakes failures To prevent recent gating problems from typos, an import not used and redefinition of function problems in the source code have become gating. Fixes: Bug #1131275 Change-Id: I7011f3ac5940afc70c38758e67a2222a66e625c3 Signed-off-by: Steven Dake --- heat/engine/service.py | 2 +- heat/tests/__init__.py | 4 ++-- heat/tests/test_common_policy.py | 3 ++- heat/tests/test_security_group.py | 2 +- heat/tests/test_vpc.py | 2 +- tools/pyflakes-bypass.py | 15 +++++++++++++++ tools/run_pep8.sh | 3 +++ 7 files changed, 25 insertions(+), 6 deletions(-) create mode 100644 tools/pyflakes-bypass.py diff --git a/heat/engine/service.py b/heat/engine/service.py index c00bf1a4..27cd83bc 100644 --- a/heat/engine/service.py +++ b/heat/engine/service.py @@ -28,7 +28,7 @@ from heat.common import exception from heat.common import identifier from heat.engine import parser from heat.engine import resource -from heat.engine import resources +from heat.engine import resources # pyflakes_bypass review 23102 from heat.engine import watchrule from heat.openstack.common import log as logging diff --git a/heat/tests/__init__.py b/heat/tests/__init__.py index 70f0b832..2d2be407 100644 --- a/heat/tests/__init__.py +++ b/heat/tests/__init__.py @@ -28,9 +28,9 @@ def reset_db(): def setup(): - import mox # Fail fast if you don't have mox. Workaround for bug 810424 + import mox # pyflakes_bypass Workaround for bug 810424 from heat.db import migration - from heat import db + from heat import db # pyflakes_bypass review 23102 reset_db() migration.db_sync() diff --git a/heat/tests/test_common_policy.py b/heat/tests/test_common_policy.py index 8730d8f9..8f64a346 100644 --- a/heat/tests/test_common_policy.py +++ b/heat/tests/test_common_policy.py @@ -20,7 +20,8 @@ from nose.plugins.attrib import attr from oslo.config import cfg import unittest -import heat.api +import heat.api # pyflakes_bypass review 23102 + from heat.common import context from heat.common import policy from heat.common import exception diff --git a/heat/tests/test_security_group.py b/heat/tests/test_security_group.py index 58418880..0364e8c9 100644 --- a/heat/tests/test_security_group.py +++ b/heat/tests/test_security_group.py @@ -22,7 +22,7 @@ from heat.engine import clients from heat.common import context from heat.common import template_format from heat.engine import parser -import heat.engine.resources +import heat.engine.resources # pyflakes_bypass review 23102 from heat.tests.v1_1 import fakes from novaclient.v1_1 import security_groups as nova_sg diff --git a/heat/tests/test_vpc.py b/heat/tests/test_vpc.py index 015fd2eb..9bc2abe5 100644 --- a/heat/tests/test_vpc.py +++ b/heat/tests/test_vpc.py @@ -22,7 +22,7 @@ from heat.common import context from heat.common import exception from heat.common import template_format from heat.engine import parser -import heat.engine.resources +import heat.engine.resources # pyflakes_bypass review 23102 try: from quantumclient.common.exceptions import QuantumClientException diff --git a/tools/pyflakes-bypass.py b/tools/pyflakes-bypass.py new file mode 100644 index 00000000..55a77642 --- /dev/null +++ b/tools/pyflakes-bypass.py @@ -0,0 +1,15 @@ +from pyflakes.scripts import pyflakes +from pyflakes.checker import Checker + + +def report_with_bypass(self, messageClass, *args, **kwargs): + text_lineno = args[0] - 1 + with open(self.filename, 'r') as code: + if code.readlines()[text_lineno].find('pyflakes_bypass') >= 0: + return + self.messages.append(messageClass(self.filename, *args, **kwargs)) + +# monkey patch checker to support bypass +Checker.report = report_with_bypass + +pyflakes.main() diff --git a/tools/run_pep8.sh b/tools/run_pep8.sh index 9a8a743a..a3921843 100755 --- a/tools/run_pep8.sh +++ b/tools/run_pep8.sh @@ -15,3 +15,6 @@ ${PEP8} ${EXCLUDE} . # Check binaries without py extension ${PEP8} bin/heat-api bin/heat-api-cfn bin/heat-api-cloudwatch bin/heat-cfn bin/heat-engine bin/heat-watch + +! python tools/pyflakes-bypass.py heat/ | grep "imported but unused\|redefinition of function" + -- 2.45.2