Skip to content

[feature] Being able to use stub pyi files in pylint #4987

@daltairwalter

Description

@daltairwalter

Bug description

I made some pyi files from pyd's using a stubgen program and I would like to use these pyi files for pylint.

I tried making some test cases with *.pyi files and they seem to be entirely ignored by pylint. I searched for other issues related to pyi/stubs and there seemed to be a few issues, but none of them said these files were just flat out unused - so I am wondering if something else is going on.

This seems to work if I delete the *.pyd files and rename the *.pyi files to *.py. Is this necessary?

When I import and use these files directly, there error messages are reasonably ignorable things like:

UseLocation.py:3:7: I1101: Module 'pylintimportstar.RealLocation' has no 'RealClass' member, but source is unavailable. Consider adding this module to extension-pkg-allow-list if you want to perform analysis based on run-time introspection of living objects. (c-extension-no-member)

Unfortunately, when used through an import statement:
from pylintimportstar.RealLocation import *
The messages are all errors:

UseLocation.py:3:7: E1101: Module 'pylintimportstar' has no 'ReferenceLocation' member (no-member)

Command used

C:\programs\anaconda3\Scripts\pylint.exe C:\test\pylintimportstar2\pylintimportstar

Pylint output

************* Module ReferenceLocation
ReferenceLocation.py:1:0: C0304: Final newline missing (missing-final-newline)
ReferenceLocation.py:1:0: C0103: Module name "ReferenceLocation" doesn't conform to snake_case naming style (invalid-name)
ReferenceLocation.py:1:0: C0114: Missing module docstring (missing-module-docstring)
ReferenceLocation.py:1:0: W0401: Wildcard import pylintimportstar.RealLocation (wildcard-import)
************* Module UseLocation
UseLocation.py:4:0: C0304: Final newline missing (missing-final-newline)
UseLocation.py:1:0: C0103: Module name "UseLocation" doesn't conform to snake_case naming style (invalid-name)
UseLocation.py:1:0: C0114: Missing module docstring (missing-module-docstring)
UseLocation.py:3:7: E1101: Module 'pylintimportstar.ReferenceLocation' has no 'RealClass' member (no-member)

Expected behavior

The error E1101 is not expected.

Pylint version

pylint 2.10.2
astroid 2.7.3
Python 3.7.4 (default, Aug  9 2019, 18:34:13) [MSC v.1915 64 bit (AMD64)]

Maintainer note: this was a duplicate of #2873 which has 11 👍 already so this is higher priority than it appear just by sorting by thumbsup.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Enhancement ✨Improvement to a componentHigh priorityIssue with more than 10 reactions

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions