Collect files for which we need to generate stubs. Return list of py modules, pyc modules, and C modules.
(
options: Options, mypy_opts: MypyOptions
)
| 1573 | |
| 1574 | |
| 1575 | def collect_build_targets( |
| 1576 | options: Options, mypy_opts: MypyOptions |
| 1577 | ) -> tuple[list[StubSource], list[StubSource], list[StubSource]]: |
| 1578 | """Collect files for which we need to generate stubs. |
| 1579 | |
| 1580 | Return list of py modules, pyc modules, and C modules. |
| 1581 | """ |
| 1582 | if options.packages or options.modules: |
| 1583 | if options.no_import: |
| 1584 | py_modules = find_module_paths_using_search( |
| 1585 | options.modules, options.packages, options.search_path, options.pyversion |
| 1586 | ) |
| 1587 | c_modules: list[StubSource] = [] |
| 1588 | else: |
| 1589 | # Using imports is the default, since we can also find C modules. |
| 1590 | py_modules, c_modules = find_module_paths_using_imports( |
| 1591 | options.modules, options.packages, options.verbose, options.quiet |
| 1592 | ) |
| 1593 | else: |
| 1594 | # Use mypy native source collection for files and directories. |
| 1595 | try: |
| 1596 | source_list = create_source_list(options.files, mypy_opts) |
| 1597 | except InvalidSourceList as e: |
| 1598 | raise SystemExit(str(e)) from e |
| 1599 | py_modules = [StubSource(m.module, m.path) for m in source_list] |
| 1600 | c_modules = [] |
| 1601 | |
| 1602 | py_modules = remove_blacklisted_modules(py_modules) |
| 1603 | pyc_mod, py_mod = split_pyc_from_py(py_modules) |
| 1604 | return py_mod, pyc_mod, c_modules |
| 1605 | |
| 1606 | |
| 1607 | def find_module_paths_using_imports( |
searching dependent graphs…