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

Created on 13 Jun 2017  路  3Comments  路  Source: PyCQA/pylint

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)]
astroid brain bug

Most helpful comment

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.

All 3 comments

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.

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

@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.

Was this page helpful?
0 / 5 - 0 ratings