diff --git a/mypy/modulefinder.py b/mypy/modulefinder.py index e6cd0f5ac9bd..fee484ae02fb 100644 --- a/mypy/modulefinder.py +++ b/mypy/modulefinder.py @@ -412,7 +412,6 @@ def _find_module(self, id: str, use_typeshed: bool) -> ModuleSearchResult: third_party_inline_dirs: PackageDirs = [] third_party_stubs_dirs: PackageDirs = [] found_possible_third_party_missing_type_hints = False - need_installed_stubs = False # Third-party stub/typed packages candidate_package_dirs = { package_dir[0] @@ -455,9 +454,6 @@ def _find_module(self, id: str, use_typeshed: bool) -> ModuleSearchResult: third_party_inline_dirs.append(non_stub_match) self._update_ns_ancestors(components, non_stub_match) - if approved_stub_package_exists(id): - need_installed_stubs = True - if self.options and self.options.use_builtins_fixtures: # Everything should be in fixtures. third_party_inline_dirs.clear() @@ -556,7 +552,7 @@ def _find_module(self, id: str, use_typeshed: bool) -> ModuleSearchResult: if ancestor is not None: return ancestor - if need_installed_stubs: + if approved_stub_package_exists(id): return ModuleNotFoundReason.APPROVED_STUBS_NOT_INSTALLED elif found_possible_third_party_missing_type_hints: return ModuleNotFoundReason.FOUND_WITHOUT_TYPE_HINTS