diff --git a/mypy/build.py b/mypy/build.py index 5d05cdbd14a1..9d0e60631909 100644 --- a/mypy/build.py +++ b/mypy/build.py @@ -91,7 +91,6 @@ from mypy.renaming import LimitedVariableRenameVisitor, VariableRenameVisitor from mypy.stats import dump_type_stats from mypy.stubinfo import ( - is_legacy_bundled_package, legacy_bundled_packages, non_bundled_packages, stub_distribution_name, @@ -2672,7 +2671,10 @@ def find_module_and_diagnose( # negatives. (Unless there are stubs but they are incomplete.) global_ignore_missing_imports = manager.options.ignore_missing_imports if ( - any(".".join(id_components[:i]) in legacy_bundled_packages for i in range(len(id_components), 0, -1)) + any( + ".".join(id_components[:i]) in legacy_bundled_packages + for i in range(len(id_components), 0, -1) + ) and global_ignore_missing_imports and not options.ignore_missing_imports_per_module and result is ModuleNotFoundReason.APPROVED_STUBS_NOT_INSTALLED diff --git a/test-data/unit/check-modules.test b/test-data/unit/check-modules.test index 36e15ce18e83..3da5996ed274 100644 --- a/test-data/unit/check-modules.test +++ b/test-data/unit/check-modules.test @@ -3138,9 +3138,11 @@ import bleach.xyz from bleach.abc import fgh [file bleach/__init__.pyi] [out] -main:1: error: Cannot find implementation or library stub for module named "bleach.xyz" +main:1: error: Library stubs not installed for "bleach.xyz" +main:1: note: Hint: "python3 -m pip install types-bleach" +main:1: note: (or run "mypy --install-types" to install all missing stub packages) main:1: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports -main:2: error: Cannot find implementation or library stub for module named "bleach.abc" +main:2: error: Library stubs not installed for "bleach.abc" [case testMissingSubmoduleOfInstalledStubPackageIgnored] # flags: --ignore-missing-imports