@@ -277,6 +277,25 @@ If you are getting this error, try to obtain type hints for the library you're u
277277 to the library -- see our documentation on creating
278278 :ref: `PEP 561 compliant packages <installed-packages >`.
279279
280+ 4. Force mypy to analyze the library as best as it can (as if the library provided
281+ a ``py.typed `` file), despite it likely missing any type annotations. In general,
282+ the quality of type checking will be poor and mypy may have issues when
283+ analyzing code not designed to be type checked.
284+
285+ You can do this via setting the
286+ :option: `--follow-untyped-imports <mypy --follow-untyped-imports> `
287+ command line flag or :confval: `follow_untyped_imports ` config file option to True.
288+ This option can be specified on a per-module basis as well::
289+
290+ # mypy.ini
291+ [mypy-untyped_package.*]
292+ follow_untyped_imports = True
293+
294+ # pyproject.toml
295+ [[tool.mypy.overrides]]
296+ module = ["untyped_package.*"]
297+ follow_untyped_imports = true
298+
280299If you are unable to find any existing type hints nor have time to write your
281300own, you can instead *suppress * the errors.
282301
@@ -295,9 +314,15 @@ not catch errors in its use.
295314 all import errors associated with that library and that library alone by
296315 adding the following section to your config file::
297316
317+ # mypy.ini
298318 [mypy-foobar.*]
299319 ignore_missing_imports = True
300320
321+ # pyproject.toml
322+ [[tool.mypy.overrides]]
323+ module = ["foobar.*"]
324+ ignore_missing_imports = true
325+
301326 Note: this option is equivalent to adding a ``# type: ignore `` to every
302327 import of ``foobar `` in your codebase. For more information, see the
303328 documentation about configuring
@@ -311,22 +336,20 @@ not catch errors in its use.
311336
312337 You can also set :confval: `disable_error_code `, like so::
313338
339+ # mypy.ini
314340 [mypy]
315341 disable_error_code = import-untyped
316342
343+ # pyproject.toml
344+ [tool.mypy]
345+ disable_error_code = ["import-untyped"]
317346
318347 You can also set the :option: `--ignore-missing-imports <mypy --ignore-missing-imports> `
319348 command line flag or set the :confval: `ignore_missing_imports ` config file
320349 option to True in the *global * section of your mypy config file. We
321350 recommend avoiding ``--ignore-missing-imports `` if possible: it's equivalent
322351 to adding a ``# type: ignore `` to all unresolved imports in your codebase.
323352
324- 4. To make mypy typecheck imports from modules without stubs or a py.typed
325- marker, you can set the :option: `--follow-untyped-imports <mypy --follow-untyped-imports> `
326- command line flag or set the :confval: `follow_untyped_imports ` config file option to True,
327- either in the global section of your mypy config file, or individually on a
328- per-module basis.
329-
330353
331354Library stubs not installed
332355---------------------------
0 commit comments