views:

105

answers:

2

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?

A: 

Update to at least pylint 0.18.1 / logilab-astng 0.19.1?

Andrew Dalke
Yup, running that. It's only when I use the dot specifically, e.g. from foo import bar works, but not from . import foo.
dd
Ahh, got. The link I found was using a relative name.
Andrew Dalke
A: 

Note that the "from . import smthg" is only allowed in a Python package.

I've tested this with

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]

and was not able to reproduce your problem:

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
gurney alex