pylint
pylint copied to clipboard
Relative imports not properly parsed
Steps to reproduce
mkdir packageecho > package/module.pyecho "from .module import *" > package/__init__.pyecho "from package import *; print(module)" > package/test.pypylint package --errors-only
Current behavior
No config file found, using default configuration
************* Module package.test
E: 1,29: Undefined variable 'module' (undefined-variable)
Expected behavior
No config file found, using default configuration
pylint --version output
No config file found, using default configuration
pylint 1.9.2,
astroid 1.6.5
Python 3.6.5 (default, Apr 4 2018, 15:01:18)
[GCC 7.3.1 20180303 (Red Hat 7.3.1-5)]
I think what's going on is that normally package/module would not be imported and give a name error, but because it's imported in __init__, it's part of the package namespace. This is edge behaviour and probably not something that should be depended on in production.