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

Stub suggestions for non-typeshed stubs #14328

Closed
hauntsaninja opened this issue Dec 20, 2022 · 5 comments · Fixed by #14737
Closed

Stub suggestions for non-typeshed stubs #14328

hauntsaninja opened this issue Dec 20, 2022 · 5 comments · Fixed by #14737
Labels

Comments

@hauntsaninja
Copy link
Collaborator

hauntsaninja commented Dec 20, 2022

Currently mypy only suggests installing stub packages if they're from typeshed. This restriction is important, because package installation can result in arbitrary code execution; potentially automatically when using --install-types.

However, we can loosen this a little bit. A concrete suggestion is to allow suggestions of stub packages that are under the same Github org as the actual package or maintained by the actual package maintainer. In particular, we've had a couple requests for lxml-stubs and pandas-stubs.

cc @JukkaL

@johnthagen
Copy link
Contributor

As someone who only learned about pandas-stubs from this issue and had been using pandas for a long time, I think a big user experience would be to curate an additional list of "popular/trusted" third party stubs.

I would also want mypy to error out if it detected pandas was being used, but pandas-stubs was not installed, like it does for other typeshed packages

main.py:1: error: Library stubs not installed for "pandas"  [import]
main.py:1: note: Hint: "python3 -m pip install pandas-stubs"
main.py:1: note: (or run "mypy --install-types" to install all missing stub packages)
main.py:1: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
Found 1 error in 1 file (checked 1 source file)

@twoertwein
Copy link

twoertwein commented Jan 9, 2023

@hauntsaninja If pandas-stubs requires changes to be suggested by mypy, please let me and @Dr-Irv know. It would be great if pandas-stubs is more "aggressively" publicized :)

edit: One change might be to add a CI run with mypy nightly to pandas-stubs.

edit: Another change/test might be to run mypy_primer with pandas-stubs installed and then create issues at pandas-stubs for the reported failures

@johnthagen
Copy link
Contributor

A good place for mypy to start would be to check out the stubs list on awesome-python-typing and perhaps select a conservative subset:

Also, @twoertwein, data-science-types is still listed there, so perhaps you could replace that with pandas-stubs?

@JukkaL
Copy link
Collaborator

JukkaL commented Jan 31, 2023

It seems reasonable to loosen the rules a bit. Perhaps we'd want the stubs to be at least somewhat established, e.g. there would have to be commit activity over N months and we should be able to find some non-trivial projects that are using the stubs. PyPI download stats could also be used as a signal.

@JukkaL
Copy link
Collaborator

JukkaL commented Jan 31, 2023

Another idea would be to first provide links to stub packages maintained outside typeshed in the mypy documentation, at least if we are unsure how mature the stubs are. We can then eventually promote stubs to be suggested by mypy if they seem to be sufficiently well-maintained and/or popular.

hauntsaninja added a commit to hauntsaninja/mypy that referenced this issue Feb 20, 2023
Resolves python#14328

Remove the sqlalchemy comment because it's now a PEP 561 package
hauntsaninja added a commit that referenced this issue Feb 20, 2023
Resolves #14328

Remove the sqlalchemy comment because it's now a PEP 561 package
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants