Skip to content

Commit eab5b50

Browse files
authored
Document new import error codes (#15840)
See #14740 My PR was pretty old and predates the nice check to ensure error codes are documented.
1 parent 78339b9 commit eab5b50

File tree

1 file changed

+34
-4
lines changed

1 file changed

+34
-4
lines changed

docs/source/error_code_list.rst

+34-4
Original file line numberDiff line numberDiff line change
@@ -648,8 +648,18 @@ the issue:
648648
649649
.. _code-import:
650650

651-
Check that import target can be found [import]
652-
----------------------------------------------
651+
Check for an issue with imports [import]
652+
----------------------------------------
653+
654+
Mypy generates an error if it can't resolve an `import` statement.
655+
This is a parent error code of `import-not-found` and `import-untyped`
656+
657+
See :ref:`ignore-missing-imports` for how to work around these errors.
658+
659+
.. _code-import-not-found:
660+
661+
Check that import target can be found [import-not-found]
662+
--------------------------------------------------------
653663

654664
Mypy generates an error if it can't find the source code or a stub file
655665
for an imported module.
@@ -658,11 +668,31 @@ Example:
658668

659669
.. code-block:: python
660670
661-
# Error: Cannot find implementation or library stub for module named 'acme' [import]
662-
import acme
671+
# Error: Cannot find implementation or library stub for module named "m0dule_with_typo" [import-not-found]
672+
import m0dule_with_typo
663673
664674
See :ref:`ignore-missing-imports` for how to work around these errors.
665675

676+
.. _code-import-untyped:
677+
678+
Check that import target can be found [import-untyped]
679+
--------------------------------------------------------
680+
681+
Mypy generates an error if it can find the source code for an imported module,
682+
but that module does not provide type annotations (via :ref:`PEP 561 <installed-packages>`).
683+
684+
Example:
685+
686+
.. code-block:: python
687+
688+
# Error: Library stubs not installed for "bs4" [import-untyped]
689+
import bs4
690+
# Error: Skipping analyzing "no_py_typed": module is installed, but missing library stubs or py.typed marker [import-untyped]
691+
import no_py_typed
692+
693+
In some cases, these errors can be fixed by installing an appropriate
694+
stub package. See :ref:`ignore-missing-imports` for more details.
695+
666696
.. _code-no-redef:
667697

668698
Check that each name is defined once [no-redef]

0 commit comments

Comments
 (0)