Find path and runtime value of __all__ (if possible) for modules and packages. This function uses runtime Python imports to get the information.
(
modules: list[str], packages: list[str], verbose: bool, quiet: bool
)
| 1605 | |
| 1606 | |
| 1607 | def find_module_paths_using_imports( |
| 1608 | modules: list[str], packages: list[str], verbose: bool, quiet: bool |
| 1609 | ) -> tuple[list[StubSource], list[StubSource]]: |
| 1610 | """Find path and runtime value of __all__ (if possible) for modules and packages. |
| 1611 | |
| 1612 | This function uses runtime Python imports to get the information. |
| 1613 | """ |
| 1614 | with ModuleInspect() as inspect: |
| 1615 | py_modules: list[StubSource] = [] |
| 1616 | c_modules: list[StubSource] = [] |
| 1617 | found = list(walk_packages(inspect, packages, verbose)) |
| 1618 | modules = modules + found |
| 1619 | modules = [ |
| 1620 | mod for mod in modules if not is_non_library_module(mod) |
| 1621 | ] # We don't want to run any tests or scripts |
| 1622 | for mod in modules: |
| 1623 | try: |
| 1624 | result = find_module_path_and_all_py3(inspect, mod, verbose) |
| 1625 | except CantImport as e: |
| 1626 | tb = traceback.format_exc() |
| 1627 | if verbose: |
| 1628 | sys.stderr.write(tb) |
| 1629 | if not quiet: |
| 1630 | report_missing(mod, e.message, tb) |
| 1631 | continue |
| 1632 | if not result: |
| 1633 | c_modules.append(StubSource(mod)) |
| 1634 | else: |
| 1635 | path, runtime_all = result |
| 1636 | py_modules.append(StubSource(mod, path, runtime_all)) |
| 1637 | return py_modules, c_modules |
| 1638 | |
| 1639 | |
| 1640 | def is_non_library_module(module: str) -> bool: |
no test coverage detected
searching dependent graphs…