| 1 |
# pylint: disable-msg=I0011,C0301,W0611 |
| 2 |
"""I found some of my scripts trigger off an AttributeError in pylint |
| 3 |
0.8.1 (with common 0.12.0 and astroid 0.13.1). |
| 4 |
|
| 5 |
Traceback (most recent call last): |
| 6 |
File "/usr/bin/pylint", line 4, in ? |
| 7 |
lint.Run(sys.argv[1:]) |
| 8 |
File "/usr/lib/python2.4/site-packages/pylint/lint.py", line 729, in __init__ |
| 9 |
linter.check(args) |
| 10 |
File "/usr/lib/python2.4/site-packages/pylint/lint.py", line 412, in check |
| 11 |
self.check_file(filepath, modname, checkers) |
| 12 |
File "/usr/lib/python2.4/site-packages/pylint/lint.py", line 426, in check_file |
| 13 |
astroid = self._check_file(filepath, modname, checkers) |
| 14 |
File "/usr/lib/python2.4/site-packages/pylint/lint.py", line 450, in _check_file |
| 15 |
self.check_astroid_module(astroid, checkers) |
| 16 |
File "/usr/lib/python2.4/site-packages/pylint/lint.py", line 494, in check_astroid_module |
| 17 |
self.astroid_events(astroid, [checker for checker in checkers |
| 18 |
File "/usr/lib/python2.4/site-packages/pylint/lint.py", line 511, in astroid_events |
| 19 |
self.astroid_events(child, checkers, _reversed_checkers) |
| 20 |
File "/usr/lib/python2.4/site-packages/pylint/lint.py", line 511, in astroid_events |
| 21 |
self.astroid_events(child, checkers, _reversed_checkers) |
| 22 |
File "/usr/lib/python2.4/site-packages/pylint/lint.py", line 508, in astroid_events |
| 23 |
checker.visit(astroid) |
| 24 |
File "/usr/lib/python2.4/site-packages/logilab/astroid/utils.py", line 84, in visit |
| 25 |
method(node) |
| 26 |
File "/usr/lib/python2.4/site-packages/pylint/checkers/variables.py", line 295, in visit_import |
| 27 |
self._check_module_attrs(node, module, name_parts[1:]) |
| 28 |
File "/usr/lib/python2.4/site-packages/pylint/checkers/variables.py", line 357, in _check_module_attrs |
| 29 |
self.add_message('E0611', args=(name, module.name), |
| 30 |
AttributeError: Import instance has no attribute 'name' |
| 31 |
|
| 32 |
|
| 33 |
You can reproduce it by: |
| 34 |
(1) create package structure like the following: |
| 35 |
|
| 36 |
package/ |
| 37 |
__init__.py |
| 38 |
subpackage/ |
| 39 |
__init__.py |
| 40 |
module.py |
| 41 |
|
| 42 |
(2) in package/__init__.py write: |
| 43 |
|
| 44 |
import subpackage |
| 45 |
|
| 46 |
(3) run pylint with a script importing package.subpackage.module. |
| 47 |
""" |
| 48 |
__revision__ = '$Id: import_package_subpackage_module.py,v 1.1 2005-11-10 15:59:32 syt Exp $' |
| 49 |
import package.subpackage.module |