From 5dafb4740fd864e8415c52f75366e45d331016cb Mon Sep 17 00:00:00 2001 From: Jukka Lehtosalo Date: Mon, 21 Jun 2021 16:08:55 +0100 Subject: [PATCH] Document --install-types --non-interactive --- docs/source/command_line.rst | 14 ++++++++++++++ docs/source/running_mypy.rst | 19 +++++++++++++++---- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/docs/source/command_line.rst b/docs/source/command_line.rst index 69d1a7b80fde..2d82d2b83517 100644 --- a/docs/source/command_line.rst +++ b/docs/source/command_line.rst @@ -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 `, 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 diff --git a/docs/source/running_mypy.rst b/docs/source/running_mypy.rst index 8a2fbc2df599..d4061fcdc103 100644 --- a/docs/source/running_mypy.rst +++ b/docs/source/running_mypy.rst @@ -182,10 +182,21 @@ mypy run. You can also use your normal mypy command line with the extra :option:`--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 ` with +:option:`--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: