[lxml-dev] using pyflakes

Hi Stefan and others, I have just checked in a Makefile target to run pyflakes on the lxml source tree: $ sudo easy_install pyflakes $ make lint pyflakes . ./selftest2.py:7: 'sys' imported but unused ./selftest2.py:7: 'StringIO' imported but unused ./setup.py:1: redefinition of unused 'os' from line 1 ./setup.py:10: redefinition of unused 'setup' from line 5 ./setup.py:11: redefinition of unused 'Extension' from line 6 ./bench.py:2: 'from itertools import *' used; unable to detect undefined names ./bench.py:632: redefinition of unused 'time' from line 1 ./selftest.py:12: 'sys' imported but unused ./selftest.py:12: 'StringIO' imported but unused ./update-error-constants.py:3: redefinition of unused 'os' from line 3 ./src/doctest.py:98: 'types' imported but unused ./src/lxml/tests/common_imports.py:11: redefinition of unused 'ElementTree' from line 9 ./src/lxml/tests/test_htmlparser.py:10: 'fileInTestDir' imported but unused ./src/lxml/tests/test_etree.py:14: 'SillyFileLike' imported but unused ./src/lxml/tests/test_errors.py:2: 'doctest' imported but unused ./src/lxml/tests/test_unicode.py:2: 'doctest' imported but unused ./src/lxml/tests/test_unicode.py:4: 'SillyFileLike' imported but unused ./src/lxml/tests/test_io.py:10: 'fileInTestDir' imported but unused ./src/lxml/tests/test_elementtree.py:11: 'doctest' imported but unused ./src/lxml/tests/test_elementtree.py:14: 'HelperTestCase' imported but unused pylint and pychecker might be useful too but pyflakes is simple and very fast. pylint is much more verbose and pychecker requires to import the modules to do its work thus needs inplace compilation first. -- Olivier

Hi Olivier, Olivier Grisel wrote:
I have just checked in a Makefile target to run pyflakes on the lxml source tree:
Hmm, may I ask, why? There isn't much code to test here. Mostly everything that's interesting is in Pyrex code, which is not checkable by any Python *lint* I heard of so far.
We didn't write those and most likely the reason for the two is that some warnings was commented out in them.
Those warnings are misleading. They are double imported depending on ImportError.
I don't think any of these are relevant. And they don't give me the impression that pyflakes is a reasonably sophisticated tool either. I'll revert the change. Stefan

Stefan Behnel a écrit :
Ok as you wish. I thought about pyflakes when I so your last commit on mkhtml.py with the shutil useless import. I find it quite handy on python projects to run before launching the tests. It's quite fast to run and finds most variable name typos that a usual compiler would find on statically typed languages. But as you said, it does not work on pyrex files. Maybe pychecker is a better choice for lxml. -- Olivier

Hi Olivier, Olivier Grisel wrote:
I thought about pyflakes when I so your last commit on mkhtml.py with the shutil useless import.
Sure, that became superfluous then. Not too much of a worry, though. That file is rarely run by normal users.
I never heard anything about pychecker being able to parse Pyrex code either. The problem is, when you add these things as Makefile targets, people will think we actually use them and start telling us about 'bugs' that these tools appear to have found. Stefan
participants (2)
-
Olivier Grisel
-
Stefan Behnel