MCPcopy Index your code
hub / github.com/python/mypy / find_lib_path_dirs

Method find_lib_path_dirs

mypy/modulefinder.py:262–276  ·  view source on GitHub ↗

Find which elements of a lib_path have the directory a module needs to exist.

(self, id: str, lib_path: tuple[str, ...])

Source from the content-addressed store, hash-verified

260 return None
261
262 def find_lib_path_dirs(self, id: str, lib_path: tuple[str, ...]) -> PackageDirs:
263 """Find which elements of a lib_path have the directory a module needs to exist."""
264 components = id.split(".")
265 dir_chain = os.sep.join(components[:-1]) # e.g., 'foo/bar'
266
267 dirs = []
268 for pathitem in self.get_toplevel_possibilities(lib_path, components[0]):
269 # e.g., '/usr/lib/python3.4/foo/bar'
270 if dir_chain:
271 dir = os_path_join(pathitem, dir_chain)
272 else:
273 dir = pathitem
274 if self.fscache.isdir(dir):
275 dirs.append((dir, True))
276 return dirs
277
278 def get_toplevel_possibilities(self, lib_path: tuple[str, ...], id: str) -> list[str]:
279 """Find which elements of lib_path could contain a particular top-level module.

Callers 1

_find_moduleMethod · 0.95

Calls 6

os_path_joinFunction · 0.90
splitMethod · 0.80
appendMethod · 0.80
joinMethod · 0.45
isdirMethod · 0.45

Tested by

no test coverage detected