MCPcopy Create free account
hub / github.com/python/mypy / collect_build_targets

Function collect_build_targets

mypy/stubgen.py:1575–1604  ·  view source on GitHub ↗

Collect files for which we need to generate stubs. Return list of py modules, pyc modules, and C modules.

(
    options: Options, mypy_opts: MypyOptions
)

Source from the content-addressed store, hash-verified

1573
1574
1575def 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
1607def find_module_paths_using_imports(

Callers 4

test_files_foundMethod · 0.90
test_packages_foundMethod · 0.90
test_module_not_foundMethod · 0.90
generate_stubsFunction · 0.85

Calls 7

create_source_listFunction · 0.90
strClass · 0.85
StubSourceClass · 0.85
split_pyc_from_pyFunction · 0.85

Tested by 3

test_files_foundMethod · 0.72
test_packages_foundMethod · 0.72
test_module_not_foundMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…