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

Function find_module_paths_using_search

mypy/stubgen.py:1681–1711  ·  view source on GitHub ↗

Find sources for modules and packages requested. This function just looks for source files at the file system level. This is used if user passes --no-import, and will not find C modules. Exit if some of the modules or packages can't be found.

(
    modules: list[str], packages: list[str], search_path: list[str], pyversion: tuple[int, int]
)

Source from the content-addressed store, hash-verified

1679
1680
1681def find_module_paths_using_search(
1682 modules: list[str], packages: list[str], search_path: list[str], pyversion: tuple[int, int]
1683) -> list[StubSource]:
1684 """Find sources for modules and packages requested.
1685
1686 This function just looks for source files at the file system level.
1687 This is used if user passes --no-import, and will not find C modules.
1688 Exit if some of the modules or packages can't be found.
1689 """
1690 result: list[StubSource] = []
1691 typeshed_path = default_lib_path(mypy.build.default_data_dir(), pyversion, None)
1692 search_paths = SearchPaths((".",) + tuple(search_path), (), (), tuple(typeshed_path))
1693 cache = FindModuleCache(search_paths, fscache=None, options=None)
1694 for module in modules:
1695 m_result = cache.find_module(module)
1696 if isinstance(m_result, ModuleNotFoundReason):
1697 fail_missing(module, m_result)
1698 module_path = None
1699 else:
1700 module_path = m_result
1701 result.append(StubSource(module, module_path))
1702 for package in packages:
1703 p_result = cache.find_modules_recursive(package)
1704 if p_result:
1705 fail_missing(package, ModuleNotFoundReason.NOT_FOUND)
1706 sources = [StubSource(m.module, m.path) for m in p_result]
1707 result.extend(sources)
1708
1709 result = [m for m in result if not is_non_library_module(m.module)]
1710
1711 return result
1712
1713
1714def mypy_options(stubgen_options: Options) -> MypyOptions:

Callers 1

collect_build_targetsFunction · 0.85

Calls 12

find_moduleMethod · 0.95
default_lib_pathFunction · 0.90
SearchPathsClass · 0.90
FindModuleCacheClass · 0.90
fail_missingFunction · 0.90
tupleClass · 0.85
isinstanceFunction · 0.85
StubSourceClass · 0.85
is_non_library_moduleFunction · 0.85
appendMethod · 0.80
extendMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…