Skip to content

Commit 1fc7d81

Browse files
add import-untyped-stubs-available, and docu (but not implementation)
1 parent 66dd2c1 commit 1fc7d81

2 files changed

Lines changed: 25 additions & 2 deletions

File tree

docs/source/error_code_list.rst

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

671671
Mypy generates an error if it can't resolve an `import` statement.
672-
This is a parent error code of `import-not-found` and `import-untyped`
672+
This is a parent error code of `import-not-found`, `import-untyped`,
673+
and `import-untyped-stubs-available`
673674

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

@@ -702,14 +703,33 @@ Example:
702703

703704
.. code-block:: python
704705
705-
# Error: Library stubs not installed for "bs4" [import-untyped]
706+
# Error: Library stubs not installed for "bs4" [import-untyped-stubs-available]
706707
import bs4
707708
# Error: Skipping analyzing "no_py_typed": module is installed, but missing library stubs or py.typed marker [import-untyped]
708709
import no_py_typed
709710
710711
In some cases, these errors can be fixed by installing an appropriate
711712
stub package. See :ref:`ignore-missing-imports` for more details.
712713

714+
Check that import target with known stubs can be found [import-untyped-stubs-available]
715+
--------------------------------------------------------
716+
717+
Like :ref:`code-import-untyped`, but used when mypy knows there is an appropriate
718+
type stub package corresponding to the library, which you could install.
719+
720+
Example:
721+
722+
.. code-block:: python
723+
724+
# Error: Library stubs not installed for "bs4" [import-untyped-stubs-available]
725+
import bs4
726+
# Error: Skipping analyzing "no_py_typed": module is installed, but missing library stubs or py.typed marker [import-untyped]
727+
import no_py_typed
728+
729+
These errors can be fixed by installing the appropriate
730+
stub package. See :ref:`ignore-missing-imports` for more details.
731+
732+
713733
.. _code-no-redef:
714734

715735
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)