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]
)
| 1679 | |
| 1680 | |
| 1681 | def 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 | |
| 1714 | def mypy_options(stubgen_options: Options) -> MypyOptions: |
no test coverage detected
searching dependent graphs…