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

Function _consolidate_submodules

scripts/update_lib/deps.py:1539–1571  ·  view source on GitHub ↗

Consolidate submodules if count exceeds threshold. Args: modules: Set of full module paths (e.g., {"urllib.request", "urllib.parse", "xml.dom", "xml.sax"}) threshold: If submodules > threshold, consolidate to parent Returns: Dict mapping display_name -> set of origi

(
    modules: set[str], threshold: int = 3
)

Source from the content-addressed store, hash-verified

1537
1538
1539def _consolidate_submodules(
1540 modules: set[str], threshold: int = 3
1541) -> dict[str, set[str]]:
1542 """Consolidate submodules if count exceeds threshold.
1543
1544 Args:
1545 modules: Set of full module paths (e.g., {"urllib.request", "urllib.parse", "xml.dom", "xml.sax"})
1546 threshold: If submodules > threshold, consolidate to parent
1547
1548 Returns:
1549 Dict mapping display_name -> set of original module paths
1550 e.g., {"urllib.request": {"urllib.request"}, "xml": {"xml.dom", "xml.sax", "xml.etree", "xml.parsers"}}
1551 """
1552 # Group by top-level package
1553 by_package: dict[str, set[str]] = {}
1554 for mod in modules:
1555 parts = mod.split(".")
1556 top = parts[0]
1557 if top not in by_package:
1558 by_package[top] = set()
1559 by_package[top].add(mod)
1560
1561 result: dict[str, set[str]] = {}
1562 for top, submods in by_package.items():
1563 if len(submods) > threshold:
1564 # Consolidate to top-level
1565 result[top] = submods
1566 else:
1567 # Keep individual
1568 for mod in submods:
1569 result[mod] = {mod}
1570
1571 return result
1572
1573
1574# Modules that are used everywhere - show but don't expand their dependents

Callers 1

Calls 5

setFunction · 0.85
lenFunction · 0.85
splitMethod · 0.45
addMethod · 0.45
itemsMethod · 0.45

Tested by

no test coverage detected