mypkg containing __init__.py and os.py__init__.py, require something from the built-in os package, e.g. from os import pathpylint __init__.py from within the mypkg directory.Pylint reports No name 'path' in module 'os' (no-name-in-module), assuming that __init__.py refers to os.py in the mypkg directory, and not the built-in os module.
The problem only manifests when pylint is invoked from the directory containing os.py.
The from os import path is identified as an absolute import, and no error is reported.
pylint --version
No config file found, using default configuration
pylint 1.8.2,
astroid 1.6.1
Python 3.6.4 (default, Mar 9 2018, 23:15:03)
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.39.2)]
Thanks for the issue, I can reproduce it.
A little more detail:
* Running pylint this way, which removes the current directory from the module path, still reproduces the issue: python -c 'import sys,runpy;sys.path.pop(0);runpy.run_module("pylint") file.py'.
- The issue does not occur if Pylint is called from a different directory
~This actually depends on the python version - it is correct for python2, but for python3 pylint will also complain when called from a different directory.~
@tilgovi is correct for both python2 and 3; thanks @giovannipizzi (+repo updated).
See this github repo with a minimum working example https://github.com/ltalirz/prospector-pylint-absolute-import
I confirm that the overall issue still persists in pylint 2.1.1, with no obvious solution or workaround.
This still seems to be a problem in pylint 2.3.1
Most helpful comment
~This actually depends on the python version - it is correct for python2, but for python3 pylint will also complain when called from a different directory.~
@tilgovi is correct for both python2 and 3; thanks @giovannipizzi (+repo updated).
See this github repo with a minimum working example https://github.com/ltalirz/prospector-pylint-absolute-import
I confirm that the overall issue still persists in pylint 2.1.1, with no obvious solution or workaround.