Relative imports don't seem to work at all. I have the following package layout (find . -name '*.py' -exec sh -c 'echo "## File $0:"; cat "$0"; echo' '{}' ';'): ## File ./test.py: #!/usr/bin/env python2.6 import testpackage.mod_a ## File ./testpackage/__init__.py: ## File ./testpackage/mod_a.py: from . import mod_b ## File ./testpackage/mod_b.py: print "Hello from mod_b" Pylint gives: ************* Module testpackage.mod_a F0401: 1: Unable to import %r W0611: 1: Unused import mod_b This happens in all my packages for all relative imports, regardless of whether __future__.absolute_imports is imported. Interestingly, this used to work in old versions of Pylint (e.g., pylint 0.15.2, which comes with Ubuntu Jaunty). | |
| priority | important |
|---|---|
| type | bug |
| appeared in | <not specified> |
| done in | 0.20.4 |
| load | 0.100 |
| load left | 0.000 |
| closed by | <not specified> |


#23008 False positive: E1101: 5: Module 'numpy' has no 'float64' member
Comments
-
2010/09/02 12:58, written by anon
| reply to this comment
(add comment)tested with pylint 0.22.2
from .foo import bar # this works
from . import foo # this produces backtrace:
Traceback (most recent call last):
File "/usr/bin/pylint-2.7", line 4, in <module>
lint.Run(sys.argv[1:])
File "/usr/lib64/python2.7/site-packages/pylint/lint.py", line 858, in __init__
linter.check(args)
File "/usr/lib64/python2.7/site-packages/pylint/lint.py", line 490, in check
self.check_astng_module(astng, walker, rawcheckers)
File "/usr/lib64/python2.7/site-packages/pylint/lint.py", line 565, in check_astng_module
walker.walk(astng)
File "/usr/lib64/python2.7/site-packages/pylint/utils.py", line 516, in walk
self.walk(child)
File "/usr/lib64/python2.7/site-packages/pylint/utils.py", line 513, in walk
cb(astng)
File "/usr/lib64/python2.7/site-packages/pylint/checkers/variables.py", line 424, in visit_from
name_parts = node.modname.split('.')
AttributeError: 'NoneType' object has no attribute 'split'