Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.pyi stub files ignored if there's no corresponding .py file #10017

Open
Hnasar opened this issue Oct 11, 2024 · 0 comments
Open

.pyi stub files ignored if there's no corresponding .py file #10017

Hnasar opened this issue Oct 11, 2024 · 0 comments
Labels
Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling pyi Message needs to become pyi-conscious

Comments

@Hnasar
Copy link
Contributor

Hnasar commented Oct 11, 2024

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

@Hnasar Hnasar added the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label Oct 11, 2024
@jacobtylerwalls jacobtylerwalls added the pyi Message needs to become pyi-conscious label Oct 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling pyi Message needs to become pyi-conscious
Projects
None yet
Development

No branches or pull requests

2 participants