From 09e8fa96c7bf821916e9a21135359d1507fa5b68 Mon Sep 17 00:00:00 2001 From: Jon Dufresne Date: Mon, 14 Dec 2020 14:24:42 -0800 Subject: [PATCH] Distribute and install py.typed to provide type information Complies with PEP 561: https://www.python.org/dev/peps/pep-0561/#packaging-type-information By distributing and installing the py.typed file, mypy will use pip's type information when imported into other projects. For example, the pip-tools project can use pip's types and mypy to help verify correctness. mypy docs: https://mypy.readthedocs.io/en/stable/installed_packages.html#making-pep-561-compatible-packages --- setup.py | 1 + src/pip/py.typed | 4 ++++ 2 files changed, 5 insertions(+) create mode 100644 src/pip/py.typed diff --git a/setup.py b/setup.py index 2601d8bd912..3c0d08c3c63 100644 --- a/setup.py +++ b/setup.py @@ -68,6 +68,7 @@ def get_version(rel_path): exclude=["contrib", "docs", "tests*", "tasks"], ), package_data={ + "pip": ["py.typed"], "pip._vendor": ["vendor.txt"], "pip._vendor.certifi": ["*.pem"], "pip._vendor.requests": ["*.pem"], diff --git a/src/pip/py.typed b/src/pip/py.typed new file mode 100644 index 00000000000..0b44fd9b5c7 --- /dev/null +++ b/src/pip/py.typed @@ -0,0 +1,4 @@ +pip is a command line program. While it is implemented in Python, and so is +available for import, you must not use pip's internal APIs in this way. Typing +information is provided as a convenience only and is not a gaurantee. Expect +unannounced changes to the API and types in releases.