MCPcopy Index your code
hub / github.com/RustPython/RustPython / _get_lib_modules_importing

Function _get_lib_modules_importing

scripts/update_lib/deps.py:1518–1536  ·  view source on GitHub ↗

Find Lib modules (full paths) that import module_name or any of its submodules.

(
    module_name: str, lib_import_graph: dict[str, set[str]]
)

Source from the content-addressed store, hash-verified

1516
1517
1518def _get_lib_modules_importing(
1519 module_name: str, lib_import_graph: dict[str, set[str]]
1520) -> set[str]:
1521 """Find Lib modules (full paths) that import module_name or any of its submodules."""
1522 importers: set[str] = set()
1523 target_top = module_name.split(".")[0]
1524
1525 for full_path, imports in lib_import_graph.items():
1526 if full_path.split(".")[0] == target_top:
1527 continue # Skip same package
1528 # Match if module imports target OR any submodule of target
1529 # e.g., for "xml": match imports of "xml", "xml.parsers", "xml.etree.ElementTree"
1530 matches = any(
1531 imp == module_name or imp.startswith(module_name + ".") for imp in imports
1532 )
1533 if matches:
1534 importers.add(full_path)
1535
1536 return importers
1537
1538
1539def _consolidate_submodules(

Callers 1

Calls 6

setFunction · 0.85
anyFunction · 0.50
splitMethod · 0.45
itemsMethod · 0.45
startswithMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected