Skip to content

Commit 680fded

Browse files
committed
Document --install-types --non-interactive (#10684)
1 parent 64deb99 commit 680fded

File tree

2 files changed

+29
-4
lines changed

2 files changed

+29
-4
lines changed

docs/source/command_line.rst

+14
Original file line numberDiff line numberDiff line change
@@ -903,6 +903,20 @@ Miscellaneous
903903
selection of third-party package stubs, instead of having
904904
them installed separately.
905905

906+
.. option:: --non-interactive
907+
908+
When used together with :option:`--install-types <mypy
909+
--install-types>`, this causes mypy to install all suggested stub
910+
packages using pip without asking for confirmation, and then
911+
continues to perform type checking using the installed stubs, if
912+
some files or modules are provided to type check.
913+
914+
This is implemented as up to two mypy runs internally. The first run
915+
is used to find missing stub packages, and output is shown from
916+
this run only if no missing stub packages were found. If missing
917+
stub packages were found, they are installed and then another run
918+
is performed.
919+
906920
.. option:: --junit-xml JUNIT_XML
907921

908922
Causes mypy to generate a JUnit XML test result document with

docs/source/running_mypy.rst

+15-4
Original file line numberDiff line numberDiff line change
@@ -182,10 +182,21 @@ mypy run. You can also use your normal mypy command line with the
182182
extra :option:`--install-types <mypy --install-types>` option to
183183
install missing stubs at the end of the run (if any were found).
184184

185-
You can also get this message if the stubs only support Python 3 and
186-
your target Python version is Python 2, or vice versa. In this case
187-
follow instructions in
188-
:ref:`missing-type-hints-for-third-party-library`.
185+
Use :option:`--install-types <mypy --install-types>` with
186+
:option:`--non-interactive <mypy --non-interactive>` to install all suggested
187+
stub packages without asking for confirmation, *and* type check your
188+
code, in a single command:
189+
190+
.. code-block:: text
191+
192+
mypy --install-types --non-interactive src/
193+
194+
This can be useful in Continuous Integration jobs if you'd prefer not
195+
to manage stub packages manually. This is somewhat slower than
196+
explicitly installing stubs before running mypy, since it may type
197+
check your code twice -- the first time to find the missing stubs, and
198+
the second time to type check your code properly after mypy has
199+
installed the stubs.
189200

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

0 commit comments

Comments
 (0)