1

If I do:

from . import foo

In a script and run pylint over it, I get:

F:  1: Unable to import %r

Is there a way a work around for getting pylint to understand this syntax?

4

2 回答 2

0

至少更新到pylint 0.18.1 / logilab-astng 0.19.1

于 2010-01-26T23:27:30.300 回答
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
于 2010-02-25T17:59:39.907 回答