Skip to content

Commit fd68921

Browse files
committed
optimise
1 parent 3ab02b1 commit fd68921

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

mypy/modulefinder.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -331,8 +331,6 @@ def _find_module_non_stub_helper(
331331
# If this is not a directory then we can't traverse further into it
332332
if not self.fscache.isdir(dir_path):
333333
break
334-
if approved_stub_package_exists(".".join(components)):
335-
return ModuleNotFoundReason.APPROVED_STUBS_NOT_INSTALLED
336334
if plausible_match:
337335
return ModuleNotFoundReason.FOUND_WITHOUT_TYPE_HINTS
338336
else:
@@ -421,10 +419,9 @@ def _find_module(self, id: str, use_typeshed: bool) -> ModuleSearchResult:
421419
for component in (components[0], components[0] + "-stubs")
422420
for package_dir in self.find_lib_path_dirs(component, self.search_paths.package_path)
423421
}
424-
for pkg_dir in [os.path.normpath(p) for p in self.search_paths.package_path]:
422+
for pkg_dir in self.search_paths.package_path:
423+
pkg_dir = os.path.normpath(pkg_dir)
425424
if pkg_dir not in candidate_package_dirs:
426-
if approved_stub_package_exists(id):
427-
need_installed_stubs = True
428425
continue
429426
stub_name = components[0] + "-stubs"
430427
stub_dir = os_path_join(pkg_dir, stub_name)
@@ -454,11 +451,13 @@ def _find_module(self, id: str, use_typeshed: bool) -> ModuleSearchResult:
454451
if isinstance(non_stub_match, ModuleNotFoundReason):
455452
if non_stub_match is ModuleNotFoundReason.FOUND_WITHOUT_TYPE_HINTS:
456453
found_possible_third_party_missing_type_hints = True
457-
elif non_stub_match is ModuleNotFoundReason.APPROVED_STUBS_NOT_INSTALLED:
458-
need_installed_stubs = True
459454
else:
460455
third_party_inline_dirs.append(non_stub_match)
461456
self._update_ns_ancestors(components, non_stub_match)
457+
458+
if approved_stub_package_exists(id):
459+
need_installed_stubs = True
460+
462461
if self.options and self.options.use_builtins_fixtures:
463462
# Everything should be in fixtures.
464463
third_party_inline_dirs.clear()

0 commit comments

Comments
 (0)