Skip to content

Commit 050632b

Browse files
add import-untyped-stubs-available, and docu (but not implementation)
1 parent 312bad8 commit 050632b

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

docs/source/error_code_list.rst

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,8 @@ Check for an issue with imports [import]
640640
----------------------------------------
641641

642642
Mypy generates an error if it can't resolve an `import` statement.
643-
This is a parent error code of `import-not-found` and `import-untyped`
643+
This is a parent error code of `import-not-found`, `import-untyped`,
644+
and `import-untyped-stubs-available`
644645

645646
See :ref:`ignore-missing-imports` for how to work around these errors.
646647

@@ -673,14 +674,33 @@ Example:
673674

674675
.. code-block:: python
675676
676-
# Error: Library stubs not installed for "bs4" [import-untyped]
677+
# Error: Library stubs not installed for "bs4" [import-untyped-stubs-available]
677678
import bs4
678679
# Error: Skipping analyzing "no_py_typed": module is installed, but missing library stubs or py.typed marker [import-untyped]
679680
import no_py_typed
680681
681682
In some cases, these errors can be fixed by installing an appropriate
682683
stub package. See :ref:`ignore-missing-imports` for more details.
683684

685+
Check that import target with known stubs can be found [import-untyped-stubs-available]
686+
--------------------------------------------------------
687+
688+
Like :ref:`code-import-untyped`, but used when mypy knows there is an appropriate
689+
type stub package corresponding to the library, which you could install.
690+
691+
Example:
692+
693+
.. code-block:: python
694+
695+
# Error: Library stubs not installed for "bs4" [import-untyped-stubs-available]
696+
import bs4
697+
# Error: Skipping analyzing "no_py_typed": module is installed, but missing library stubs or py.typed marker [import-untyped]
698+
import no_py_typed
699+
700+
These errors can be fixed by installing the appropriate
701+
stub package. See :ref:`ignore-missing-imports` for more details.
702+
703+
684704
.. _code-no-redef:
685705

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

mypy/errorcodes.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,9 @@ def __hash__(self) -> int:
113113
IMPORT_UNTYPED: Final = ErrorCode(
114114
"import-untyped", "Require that imported module has stubs", "General", sub_code_of=IMPORT
115115
)
116+
IMPORT_UNTYPED_STUBS_AVAILABLE: Final = ErrorCode(
117+
"import-untyped-stubs-available", "Require that imported module (with known stubs) has stubs", "General", sub_code_of=IMPORT
118+
)
116119
NO_REDEF: Final = ErrorCode("no-redef", "Check that each name is defined once", "General")
117120
FUNC_RETURNS_VALUE: Final = ErrorCode(
118121
"func-returns-value", "Check that called function returns a value in value context", "General"

0 commit comments

Comments
 (0)