]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Add pyflakes
authorChuck Short <chuck.short@canonical.com>
Wed, 2 Jan 2013 14:43:53 +0000 (08:43 -0600)
committerChuck Short <chuck.short@canonical.com>
Wed, 2 Jan 2013 14:44:42 +0000 (08:44 -0600)
Add tox option to use pyflakes.

Change-Id: Ic77ec3f54cb89341d5b01feb3417e07f43d20c9c
Signed-off-by: Chuck Short <chuck.short@canonical.com>
tools/flakes.py [new file with mode: 0644]
tox.ini

diff --git a/tools/flakes.py b/tools/flakes.py
new file mode 100644 (file)
index 0000000..4b93abc
--- /dev/null
@@ -0,0 +1,22 @@
+"""
+ wrapper for pyflakes to ignore gettext based warning:
+     "undefined name '_'"
+
+ From https://bugs.launchpad.net/pyflakes/+bug/844592
+"""
+import __builtin__
+import os
+import sys
+
+from pyflakes.scripts.pyflakes import main
+
+if __name__ == "__main__":
+    names = os.environ.get('PYFLAKES_BUILTINS', '_')
+    names = [x.strip() for x in names.split(',')]
+    for x in names:
+        if not hasattr(__builtin__, x):
+            setattr(__builtin__, x, True)
+
+    del names, os, __builtin__
+
+    sys.exit(main())
diff --git a/tox.ini b/tox.ini
index e766f16357fd5937392acab4078bdeafb8491968..936ba66a4536009d7a1e0cdf0de0cd70b9a504c5 100644 (file)
--- a/tox.ini
+++ b/tox.ini
@@ -44,3 +44,7 @@ commands = /bin/bash run_tests.sh -N --coverage-xml
 [testenv:jenkinsvenv]
 setenv = NOSE_WITH_XUNIT=1
 commands = {posargs}
+
+[testenv:pyflakes]
+deps = pyflakes
+commands = python tools/flakes.py cinder