@@ -322,34 +322,27 @@ the library, you will get a message like this:
322322 main.py:1: note: Hint: "python3 -m pip install types-PyYAML"
323323 main.py:1: note: (or run "mypy --install-types" to install all missing stub packages)
324324
325- You can resolve the issue by running the suggested pip command or
326- commands. Alternatively, you can use :option: `--install-types <mypy
327- --install-types> ` to install all known missing stubs:
325+ You can resolve the issue by running the suggested pip commands.
326+ If you're running mypy in CI, you can ensure the presence of any stub packages
327+ you need the same as you would any other test dependency, e.g. by adding them to
328+ the appropriate ``requirements.txt `` file.
328329
329- .. code-block :: text
330-
331- mypy --install-types
332-
333- This installs any stub packages that were suggested in the previous
334- mypy run. You can also use your normal mypy command line with the
335- extra :option: `--install-types <mypy --install-types> ` option to
336- install missing stubs at the end of the run (if any were found).
337-
338- Use :option: `--install-types <mypy --install-types> ` with
339- :option: `--non-interactive <mypy --non-interactive> ` to install all suggested
340- stub packages without asking for confirmation, *and * type check your
341- code, in a single command:
330+ Alternatively, add the :option: `--install-types <mypy --install-types> `
331+ to your mypy command to install all known missing stubs:
342332
343333.. code-block :: text
344334
345- mypy --install-types --non-interactive src/
335+ mypy --install-types
346336
347- This can be useful in Continuous Integration jobs if you'd prefer not
348- to manage stub packages manually. This is somewhat slower than
349- explicitly installing stubs before running mypy, since it may type
350- check your code twice -- the first time to find the missing stubs, and
337+ This is slower than explicitly installing stubs, since if effectively
338+ runs mypy twice -- the first time to find the missing stubs, and
351339the second time to type check your code properly after mypy has
352- installed the stubs.
340+ installed the stubs. It also can make controlling stub versions harder,
341+ resulting in less reproducible type checking.
342+
343+ By default, :option: `--install-types <mypy --install-types> ` shows a confirmation prompt.
344+ Use :option: `--non-interactive <mypy --non-interactive> ` to install all suggested
345+ stub packages without asking for confirmation *and * type check your code:
353346
354347If you've already installed the relevant third-party libraries in an environment
355348other than the one mypy is running in, you can use :option: `--python-executable
@@ -394,15 +387,6 @@ this error, try:
394387 you must run ``mypy ~/foo-project/src `` (or set the ``MYPYPATH `` to
395388 ``~/foo-project/src ``.
396389
397- In some rare cases, you may get the "Cannot find implementation or library
398- stub for module" error even when the module is installed in your system.
399- This can happen when the module is both missing type hints and is installed
400- on your system in an unconventional way.
401-
402- In this case, follow the steps above on how to handle
403- :ref: `missing type hints in third party libraries <missing-type-hints-for-third-party-library >`.
404-
405-
406390.. _finding-imports :
407391
408392How imports are found
0 commit comments