@@ -31,8 +31,8 @@ invocation to your codebase, or adding your mypy invocation to
3131existing tools you use to run tests, like ``tox ``.
3232
3333* Make sure everyone runs mypy with the same options. Checking a mypy
34- :ref: `configuration file <config-file >` into your codebase can help
35- with this.
34+ :ref: `configuration file <config-file >` into your codebase is the
35+ easiest way to do this.
3636
3737* Make sure everyone type checks the same set of files. See
3838 :ref: `specifying-code-to-be-checked ` for details.
@@ -48,7 +48,7 @@ A simple CI script could look something like this:
4848
4949.. code-block :: text
5050
51- python3 -m pip install mypy==0.971
51+ python3 -m pip install mypy==1.8
5252 # Run your standardised mypy invocation, e.g.
5353 mypy my_project
5454 # This could also look like `scripts/run_mypy.sh`, `tox run -e mypy`, `make mypy`, etc
@@ -74,6 +74,11 @@ You could even invert this, by setting ``ignore_errors = True`` in your global
7474config section and only enabling error reporting with ``ignore_errors = False ``
7575for the set of modules you are ready to type check.
7676
77+ The per-module configuration that mypy's configuration file allows can be
78+ extremely useful. Many configuration options can be enabled or disabled
79+ only for specific modules. In particular, you can also enable or disable
80+ various error codes on a per-module basis, see :ref: `error-codes `.
81+
7782Fixing errors related to imports
7883--------------------------------
7984
@@ -89,7 +94,7 @@ that it can't find, that don't have types, or don't have stub files:
8994 Sometimes these can be fixed by installing the relevant packages or
9095stub libraries in the environment you're running ``mypy `` in.
9196
92- See :ref: `ignore -missing-imports ` for a complete reference on these errors
97+ See :ref: `fix -missing-imports ` for a complete reference on these errors
9398and the ways in which you can fix them.
9499
95100You'll likely find that you want to suppress all errors from importing
@@ -118,13 +123,15 @@ codebase, use a config like this:
118123 ignore_missing_imports = True
119124
120125 If you get a large number of errors, you may want to ignore all errors
121- about missing imports, for instance by setting :confval: `ignore_missing_imports `
122- to true globally. This can hide errors later on, so we recommend avoiding this
126+ about missing imports, for instance by setting
127+ :option: `--disable-error-code=import-untyped <mypy --ignore-missing-imports> `.
128+ or setting :confval: `ignore_missing_imports ` to true globally.
129+ This can hide errors later on, so we recommend avoiding this
123130if possible.
124131
125132Finally, mypy allows fine-grained control over specific import following
126133behaviour. It's very easy to silently shoot yourself in the foot when playing
127- around with these, so it's mostly recommended as a last resort. For more
134+ around with these, so this should be a last resort. For more
128135details, look :ref: `here <follow-imports >`.
129136
130137Prioritise annotating widely imported modules
0 commit comments