Skip to content

Need a standard for searching stub files #184

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

Closed
gvanrossum opened this issue Feb 25, 2016 · 4 comments
Closed

Need a standard for searching stub files #184

gvanrossum opened this issue Feb 25, 2016 · 4 comments

Comments

@gvanrossum
Copy link
Member

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.

@gvanrossum
Copy link
Member Author

Reported to PyCharm as https://youtrack.jetbrains.com/issue/PY-18597

@vlasovskikh
Copy link
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?

@vlasovskikh
Copy link
Member

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

@ilevkivskyi
Copy link
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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants