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

Make stubs installable from github #338

Merged
merged 1 commit into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ bld/
[Oo]bj/
[Ll]og/
[Ll]ogs/
[Bb]uild/

# JetBrains
.idea
Expand Down
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@ We recognize that there may be cases where type stubs are more appropriate, such
- Package authors who do not want to include type annotations, and
- Large, complex packages where adding type annotations can take time, and stubs may be an appropriate intermediate step.

## Installing our stubs

Whilst these stubs come bundled with Pylance, we recognize it can be beneficial to install them
so that type-checkers such as [Pyright](https://github.com/microsoft/pyright) and [mypy](https://github.com/python/mypy) pick up on them.
The stubs are not currently published on PyPI, but you can install them all at once with:

```shell
pip install git+https://github.com/microsoft/python-type-stubs.git
```

## Upstreamed libraries

Stubs for the following libraries now exist in typeshed or the libraries themselves and are no longer maintained here:
Expand All @@ -52,7 +62,7 @@ Stubs for the following libraries now exist in typeshed or the libraries themsel
- pygame
- pywin32 (pythonwin, win32 and win32com packages)
- retry
- scipy (see https://github.com/jorenham/scipy-stubs)
- scipy (see <https://github.com/jorenham/scipy-stubs>)
- slugify
- SQLAlchemy (see <https://pypi.org/project/types-SQLAlchemy/> for SQLAlchemy 1.4; 2.0.0 and above include type annotations)
- tenacity
Expand Down
23 changes: 23 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
[build-system]
requires = ["setuptools >= 69.0"] # v69 includes type information by default
build-backend = "setuptools.build_meta"

[project]
name="microsoft-python-type-stubs"
dynamic = ["version"]

# Allow these stubs to be installed from GitHub
# We need an explicit mapping instead of just
# [tool.setuptools]
# package-dir = {"" = "stubs"}
# because the folder names don't all match "*-stubs"
# see https://github.com/microsoft/python-type-stubs/issues/315
[tool.setuptools.package-dir]
# See README.md as to why matplotlib is not included
"networkx-stubs" = "stubs/networkx"
"skimage-stubs" = "stubs/skimage"
"sklearn-stubs" = "stubs/sklearn"
"sympy-stubs" = "stubs/sympy-stubs"
"transformers-stubs" = "stubs/transformers-stubs"
"vispy-stubs" = "stubs/vispy"
Comment on lines +9 to +22
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With #315 , this would become

Suggested change
# Allow these stubs to be installed from GitHub
# We need an explicit mapping instead of just
# [tool.setuptools]
# package-dir = {"" = "stubs"}
# because the folder names don't all match "*-stubs"
# see https://github.com/microsoft/python-type-stubs/issues/315
[tool.setuptools.package-dir]
# See README.md as to why matplotlib is not included
"networkx-stubs" = "stubs/networkx"
"skimage-stubs" = "stubs/skimage"
"sklearn-stubs" = "stubs/sklearn"
"sympy-stubs" = "stubs/sympy-stubs"
"transformers-stubs" = "stubs/transformers-stubs"
"vispy-stubs" = "stubs/vispy"
# Allow these stubs to be installed from GitHub
[tool.setuptools]
package-dir = {"" = "stubs"}

But then it would include matplotlib, maybe we do want to keep it explicit ?


[tool.ruff]
line-length = 130
# Target oldest supported Python version
Expand Down
Loading