Esempio n. 1
0
 def _find_module_non_stub_helper(
         self, components: List[str],
         pkg_dir: str) -> Union[OnePackageDir, ModuleNotFoundReason]:
     plausible_match = False
     dir_path = pkg_dir
     for index, component in enumerate(components):
         dir_path = os.path.join(dir_path, component)
         if self.fscache.isfile(os.path.join(dir_path, 'py.typed')):
             return os.path.join(pkg_dir, *components[:-1]), index == 0
         elif not plausible_match and (self.fscache.isdir(dir_path)
                                       or self.fscache.isfile(dir_path +
                                                              ".py")):
             plausible_match = True
     if is_legacy_bundled_package(components[0], self.python_major_ver):
         if (len(components) == 1
                 or (self.find_module(components[0]) is
                     ModuleNotFoundReason.APPROVED_STUBS_NOT_INSTALLED)):
             return ModuleNotFoundReason.APPROVED_STUBS_NOT_INSTALLED
     if is_legacy_bundled_package('.'.join(components[:2]),
                                  self.python_major_ver):
         return ModuleNotFoundReason.APPROVED_STUBS_NOT_INSTALLED
     if plausible_match:
         return ModuleNotFoundReason.FOUND_WITHOUT_TYPE_HINTS
     else:
         return ModuleNotFoundReason.NOT_FOUND
Esempio n. 2
0
    def test_is_legacy_bundled_packages(self) -> None:
        assert not is_legacy_bundled_package('foobar_asdf', 2)
        assert not is_legacy_bundled_package('foobar_asdf', 3)

        assert is_legacy_bundled_package('click', 2)
        assert is_legacy_bundled_package('click', 3)

        assert is_legacy_bundled_package('scribe', 2)
        assert not is_legacy_bundled_package('scribe', 3)

        assert not is_legacy_bundled_package('dataclasses', 2)
        assert is_legacy_bundled_package('dataclasses', 3)