You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# lib/__init__.pyi__all__== ["bar"]
from ._fooimportbar
# lib/_foo.pydefbar():
print("I'm happy")
# test.pyfromlibimportbarbar()
Running test.py executes as expected but pylint is reporting an error.
conda activate pylint_env
python test.py # works and prints "I'm happy"
pylint test.py # fails with
# test.py:1:0: E0611: No name 'bar' in module 'lib' (no-name-in-module)
I'd like to add some context. lazy_loader tries to account for precisely this case by providing lazy_loader.attach_stub. That function populates the namespace of where attach_stub is called with the namespace indicated by a PYI file. I haven't looked up any official recommendations or PEPs on this, but my impression is, that most IDEs and type checkers will give PYI files priority for static analysis.
So depending on the above, this might not be a problem with specific to lazy_loader, depending on how Pylint takes PYI files into account during analysis.
Bug description
Pylint is reporting an invalid
no-name-in-module
when a module is usinglazy_loader
. This was tested in a conda environment created by:Creating a dummy library example:
Running
test.py
executes as expected butpylint
is reporting an error.Configuration
No response
Command used
Pylint output
Expected behavior
I would expect the
no-name-in-module
error to not be reported.Pylint version
OS / Environment
RHEL7
Additional dependencies
The text was updated successfully, but these errors were encountered: