pylint
pylint copied to clipboard
Spurious `no-name-in-module, import-error` with `py`
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)]
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.