Skip to content

Need a standard for searching stub files #184

Description

@gvanrossum

From python/mypy#1190 (comment):

We just encountered an issue here where there's a discrepancy between the way PyCharm and mypy search for stubs. In this case it was about an extension module, for which the user had created a stub file (but not added it to typeshed). Mypy found it fine on the default module search path. But PyCharm would only find it if there was a corresponding .py file in the same directory. In their case the fix was to add a .py file that simple re-exported the extension module. But it would be nice to have some kind of standardization for this.

Activity

  1. gvanrossum commented on Feb 25, 2016

    @gvanrossum
    MemberAuthor
  2. vlasovskikh commented on Feb 26, 2016

    @vlasovskikh
    Member

    PEP 484 already specifies how tools should handle search path:

    • The type checker should have a configurable search path for stub files.
    • The easiest form of stub file storage and distribution is to put them alongside Python modules in the same directory.
    • Third-party stub packages can use any location for stub storage. Type checkers should search for them using PYTHONPATH.
    • Default fallback directory that is always checked is shared/typehints/pythonX.X/.

    However the PEP doesn't specify two things:

    1. Should the type checker search in its configurable search path first and then move to the with the *.py file followed by the entries in sys.path?
    2. What's the search priority of the typeshed stubs if they are bundled with the type checker?
  3. vlasovskikh commented on Feb 7, 2017

    @vlasovskikh
    Member

    PyCharm 2017.1 EAP builds now always prefer stub files over Python files found on the Python path.

  4. ilevkivskyi commented on Jun 20, 2019

    @ilevkivskyi
    Member

    I think the remaining questions here were standardized by PEP 561, so this can be closed now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions