pylint icon indicating copy to clipboard operation
pylint copied to clipboard

Spurious `no-name-in-module, import-error` with `py`

Open adamtheturtle opened this issue 8 years ago • 3 comments

Steps to reproduce

pip install pylint py

Create a file with the following content:

"""
Example file for pylint.
"""

from py.path import local

print(local('/etc/example.txt'))

Run pylint on this file.

Current behavior

no-name-in-module error is given. import-error is given.

Expected behavior

No error is given - this file works in Python.

pylint --version output

No config file found, using default configuration
pylint 1.7.1,
astroid 1.5.3
Python 3.6.1 (default, Apr  4 2017, 09:40:21)
[GCC 4.2.1 Compatible Apple LLVM 8.1.0 (clang-802.0.38)]

adamtheturtle avatar Jun 13 '17 11:06 adamtheturtle

Thanks for submitting an issue!

Namespace is populated automagically, we won't be able to infer it by generic mechanisms. To support this we would need astroid.brain hint.

rogalski avatar Jun 14 '17 14:06 rogalski

What's the recommended solution to deal with this issue?

Kilo59 avatar Aug 17 '18 22:08 Kilo59

@Kilo59 The recommended solution would be to provide a brain tip in astroid for this py module.

Here's an example for numpy: https://github.com/PyCQA/astroid/blob/master/astroid/brain/brain_numpy.py#L467. We'd need something similar for py, which should provide the members that pylint cannot currently infer due to how py it's being written. I'm not familiar with py, so if you have some time to work on a patch, that would be amazing.

PCManticore avatar Aug 21 '18 07:08 PCManticore