Skip to content

Commit

Permalink
Document --install-types --non-interactive (#10684)
Browse files Browse the repository at this point in the history
  • Loading branch information
JukkaL committed Jun 22, 2021
1 parent 64deb99 commit 680fded
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
14 changes: 14 additions & 0 deletions docs/source/command_line.rst
Original file line number Diff line number Diff line change
Expand Up @@ -903,6 +903,20 @@ Miscellaneous
selection of third-party package stubs, instead of having
them installed separately.

.. option:: --non-interactive

When used together with :option:`--install-types <mypy
--install-types>`, this causes mypy to install all suggested stub
packages using pip without asking for confirmation, and then
continues to perform type checking using the installed stubs, if
some files or modules are provided to type check.

This is implemented as up to two mypy runs internally. The first run
is used to find missing stub packages, and output is shown from
this run only if no missing stub packages were found. If missing
stub packages were found, they are installed and then another run
is performed.

.. option:: --junit-xml JUNIT_XML

Causes mypy to generate a JUnit XML test result document with
Expand Down
19 changes: 15 additions & 4 deletions docs/source/running_mypy.rst
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,21 @@ mypy run. You can also use your normal mypy command line with the
extra :option:`--install-types <mypy --install-types>` option to
install missing stubs at the end of the run (if any were found).

You can also get this message if the stubs only support Python 3 and
your target Python version is Python 2, or vice versa. In this case
follow instructions in
:ref:`missing-type-hints-for-third-party-library`.
Use :option:`--install-types <mypy --install-types>` with
:option:`--non-interactive <mypy --non-interactive>` to install all suggested
stub packages without asking for confirmation, *and* type check your
code, in a single command:

.. code-block:: text
mypy --install-types --non-interactive src/
This can be useful in Continuous Integration jobs if you'd prefer not
to manage stub packages manually. This is somewhat slower than
explicitly installing stubs before running mypy, since it may type
check your code twice -- the first time to find the missing stubs, and
the second time to type check your code properly after mypy has
installed the stubs.

.. _missing-type-hints-for-third-party-library:

Expand Down

0 comments on commit 680fded

Please sign in to comment.