Skip to content

Recognize __init__.pyi to lint stub files #2873

@jolaf

Description

@jolaf

I'm creating *.pyi stubs for large libraries and I'd like to use pylint (as well as mypy) to make sure the stubs are clean.

The files I'm trying to lint are located in a directory hierarchy having __init__.pyi file in each subdirectory. Unfortunately, pylint only detects __init__.py as a "submodule root" and treats __init__.pyi as a regular file, not a submodule root, so it can't properly recognized objects defined in them.

I would suggest the following behaviour:

  • If import of an object from a module is located in a .py file, the source code for that object should be looked up in a corresponding __init__.py file, as it is now.

  • If import of an object from a module is located in a .pyi file, the source code for that object should be looked up in a corresponding __init__.pyi file, not __init__.py file, as it is does now.

Metadata

Metadata

Assignees

No one assigned

    Labels

    AstroidRelated to astroidDuplicate 🐫Duplicate of an already existing issueEnhancement ✨Improvement to a componentHigh priorityIssue with more than 10 reactionsImport systemNeeds PRThis issue is accepted, sufficiently specified and now needs an implementation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions