Skip to content

Commit 8b0f022

Browse files
emmatypinggvanrossum
authored andcommitted
Document stub-only packages incompatibility with MYPYPATH (#5428)
Closes #5386
1 parent 5e8815e commit 8b0f022

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

docs/source/installed_packages.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@ imports, namespace packages, and custom import hooks.
3030
If you do not want to use typed packages, use the ``--no-site-packages`` flag
3131
to disable searching.
3232

33+
Note that stub-only packages (defined in
34+
`PEP 561 <https://www.python.org/dev/peps/pep-0561/#stub-only-packages>`_)
35+
cannot be used with ``MYPYPATH``. If you want mypy to find the package, it must
36+
be installed. For a package ``foo``, the name of the stub-only package
37+
(``foo-stubs``) is not a legal package name, so mypy will not find it, unless
38+
it is installed.
39+
3340
Making PEP 561 compatible packages
3441
**********************************
3542

docs/source/running_mypy.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,11 @@ This is computed from the following items:
304304
- The relevant directories of the
305305
`typeshed <https://github.com/python/typeshed>`_ repo.
306306

307+
.. note::
308+
309+
You cannot point to a PEP 561 package via the MYPYPATH, it must be
310+
installed (see :ref:`PEP 561 support <installed-packages>`)
311+
307312
For sources given on the command line, the path is adjusted by crawling
308313
up from the given file or package to the nearest directory that does not
309314
contain an ``__init__.py`` or ``__init__.pyi`` file.

docs/source/stubs.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ Here is an overview of how to create a stub file:
2525
$ export MYPYPATH=~/work/myproject/stubs
2626

2727
Use the normal Python file name conventions for modules, e.g. ``csv.pyi``
28-
for module ``csv``. Use a subdirectory with ``__init__.pyi`` for packages.
28+
for module ``csv``. Use a subdirectory with ``__init__.pyi`` for packages. Note
29+
that `PEP 561 <https://www.python.org/dev/peps/pep-0561/>`_ stub-only packages
30+
must be installed, and may not be pointed at through the ``MYPYPATH``
31+
(see :ref:`PEP 561 support <installed-packages>`).
2932

3033
If a directory contains both a ``.py`` and a ``.pyi`` file for the
3134
same module, the ``.pyi`` file takes precedence. This way you can

0 commit comments

Comments
 (0)