diff --git a/tools/flakes.py b/tools/flakes.py new file mode 100644 index 000000000..4b93abc21 --- /dev/null +++ b/tools/flakes.py @@ -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 5f4682a0a..34a7d81fb 100644 --- a/tox.ini +++ b/tox.ini @@ -36,3 +36,7 @@ deps = -r{toxinidir}/tools/test-requires-folsom [testenv:py27-folsom] deps = -r{toxinidir}/tools/test-requires-folsom -r{toxinidir}/tools/pip-requires + +[testenv:pyflakes] +deps = pyflakes +commands = python tools/flakes.py ceilometer