如果我这样做:
from . import foo
在脚本中运行pylint,我得到:
F: 1: Unable to import %r
有没有办法让pylint理解这种语法?
答案 0 :(得分:0)
答案 1 :(得分:0)
请注意,“from。import smthg”仅允许在Python包中使用。
我用
进行了测试pylint --version
No config file found, using default configuration
pylint 0.19.0,
astng 0.19.1, common 0.46.0
Python 2.5.5 (r255:77872, Feb 1 2010, 19:53:42)
[GCC 4.4.3]
并且无法重现您的问题:
alf@lacapelle:/tmp$ ls package/
foo.py __init__.py relative.py
alf@lacapelle:/tmp$ cat package/relative.py
from . import foo
alf@lacapelle:/tmp$ pylint -r n package/
No config file found, using default configuration
************* Module package
C: 1: Missing docstring
************* Module package.foo
C: 1: Black listed name "foo"
C: 1: Missing docstring
************* Module package.relative
C: 1: Missing docstring
W: 1: Unused import foo