[Python-projects] pylint: (missing) namespace package handling / TypeError: '_Yes' object is unindexable
Jürgen Hermann
Juergen.Hermann at 1und1.de
Mon Mar 30 11:26:21 CEST 2009
Hi, after upgrading from 0.14 to 0.18 since 0.14 had problems handling a project using namespace packages, all I get is following traceback.
Traceback (most recent call last):
File "./bin/pylint", line 5, in <module>
pkg_resources.run_script('pylint==0.18.0', 'pylint')
File "./lib/python2.5/site-packages/setuptools-0.6c9-py2.5.egg/pkg_resources.py", line 448, in run_script
File "./lib/python2.5/site-packages/setuptools-0.6c9-py2.5.egg/pkg_resources.py", line 1166, in run_script
File "./lib/python2.5/site-packages/pylint-0.18.0-py2.5.egg/EGG-INFO/scripts/pylint", line 4, in <module>
lint.Run(sys.argv[1:])
File "./lib/python2.5/site-packages/pylint-0.18.0-py2.5.egg/pylint/lint.py", line 881, in __init__
linter.check(args)
File "./lib/python2.5/site-packages/pylint-0.18.0-py2.5.egg/pylint/lint.py", line 500, in check
self.check_astng_module(astng, checkers)
File "./lib/python2.5/site-packages/pylint-0.18.0-py2.5.egg/pylint/lint.py", line 577, in check_astng_module
if implements(checker, IASTNGChecker)])
File "./lib/python2.5/site-packages/pylint-0.18.0-py2.5.egg/pylint/lint.py", line 594, in astng_events
self.astng_events(child, checkers, _reversed_checkers)
File "./lib/python2.5/site-packages/pylint-0.18.0-py2.5.egg/pylint/lint.py", line 591, in astng_events
checker.visit(astng)
File "./lib/python2.5/site-packages/logilab_astng-0.19.0-py2.5.egg/logilab/astng/utils.py", line 320, in visit
method(node)
File "./lib/python2.5/site-packages/pylint-0.18.0-py2.5.egg/pylint/checkers/variables.py", line 415, in visit_from
module = self._check_module_attrs(node, module, name_parts[1:])
File "./lib/python2.5/site-packages/pylint-0.18.0-py2.5.egg/pylint/checkers/variables.py", line 460, in _check_module_attrs
module = module.getattr(name)[0].infer().next()
TypeError: '_Yes' object is unindexable
Changing the except clause for E0611 in variables.py to include "TypeError" yields this:
************* Module ui_portal.tools.servercontrol.java.tomcat
E0611: 16: No name 'utils' in module YES
F0401: 16: Unable to import 'ui_portal.commons.utils.adt' (No module named commons)
E0611: 17: No name 'servercontrol' in module YES
Seems the problem of 0.14 to handle namespace packages persists and is even worse.
The project structure is as follows:
* ui_portal, ui_portal.tools and ui_portal.commons are all namespace packages
* ui_portal.tools.servercontrol is the main project defining "ui_portal", "ui_portal.tools" as its namespace packages (in setup.py)
* it depends on ui_portal.commons.utils, which defines "ui_portal", "ui_portal.commons" as its namespace packages (in setup.py)
My assumption is that pylint fails as soon as you have a project that includes another egg sharing parts of the same namespace packages (in this case "ui_portal"). The "ui_portal.commons.utils" project works without problems (no dependencies to other projects in the "ui_portal" namespace). Another project that also has such a dependency shows the same symptoms. If I change one of the tools projects to include the library using "ui_portal_commons" instead of "ui_portal.commons" as the namespace, pylint works.
Previous versions:
pylint 0.14.0,
astng 0.17.2, common 0.28.2
Python 2.5.2 (r252:60911, Nov 14 2008, 19:46:32)
[GCC 4.3.2]
New versions:
pylint 0.18.0,
astng 0.19.0, common 0.39.0
Python 2.5.2 (r252:60911, Nov 14 2008, 19:46:32)
[GCC 4.3.2]
In another project using PasteScript, I get this:
E0611: 18: No name 'script' in module 'paste'
on imports like
from paste.script import templates
("paste" is a namespace package). This renders pylint quite unusable in those situations.
Bye, Jürgen
More information about the Python-Projects
mailing list