pylint
pylint copied to clipboard
.pyi stub files ignored if there's no corresponding .py file
Bug description
pylint should honor .pyi files even if there's no corresponding .py file (and even without --prefer-stubs)
My use-case is having a linting environment without building my compiled extension .so modules.
(although it sounds similar, this is different from #9097, which is for linting the .pyi files — this is about using them to lint other files)
Configuration
No response
Command used
mkdir -p asdf; echo "import bar" > asdf/foo.py; touch asdf/bar.pyi; pylint -E asdf/foo.py
Pylint output
************* Module foo
asdf/foo.py:1:0: E0401: Unable to import 'bar' (import-error)
Expected behavior
No error.
Workaround
If the .py exists and I pass --prefer-stubs y then it does what I want
mkdir -p asdf; echo "from bar import baz" > asdf/foo.py; \
touch asdf/bar.py; echo "baz = 1" > asdf/bar.pyi; pylint -E --prefer-stubs y asdf/foo.py
# no errors
Pylint version
pylint 3.2.6 astroid 3.2.4 Python 3.11.10 (main, Sep 26 2024, 17:38:01) [GCC 11.2.0]
OS / Environment
No response
Additional dependencies
No response