@@ -433,8 +433,9 @@ def analyze(self) -> PyApplication:
433433 logger .info ("✅ Jedi: %d edges in %.1fs" , len (call_graph ), time .perf_counter () - t0_jedi )
434434
435435 if self .analysis_level >= 2 :
436- # Level 2: also add PyCG edges.
437- pycg_edges = self ._get_pycg_call_graph (symbol_table )
436+ # Level 2: also add PyCG edges. The Jedi edges double as the
437+ # coupling graph that drives coupling-aware PyCG sharding.
438+ pycg_edges = self ._get_pycg_call_graph (symbol_table , jedi_edges )
438439 call_graph = merge_edges (call_graph , pycg_edges )
439440
440441 call_graph = filter_external_edges (call_graph , symbol_table )
@@ -661,13 +662,18 @@ def _build_symbol_table(self, cached_symbol_table: Optional[Dict[str, PyModule]]
661662 def _get_pycg_call_graph (
662663 self ,
663664 symbol_table : Dict [str , PyModule ],
665+ jedi_edges : List [PyCallEdge ],
664666 ) -> List [PyCallEdge ]:
665667 """Build PyCG-resolved call edges.
666668
667669 Runs PyCG's iterative name-pointer analysis over the whole project
668670 and returns edges with ``provenance=["pycg"]``. Falls back to an
669671 empty list and logs a warning on any failure so the caller can
670672 continue with Jedi-only edges.
673+
674+ *jedi_edges* are the level-1 call edges; under the ``jedi`` shard
675+ strategy they drive coupling-aware partitioning (see
676+ :func:`shard_planner.plan_shards`).
671677 """
672678 try :
673679 pycg = PyCG (
@@ -676,9 +682,11 @@ def _get_pycg_call_graph(
676682 shard = self .options .pycg_shard ,
677683 shard_ceiling = self .options .pycg_shard_ceiling ,
678684 shard_timeout = self .options .pycg_shard_timeout ,
685+ shard_strategy = self .options .pycg_shard_strategy ,
686+ max_iter = self .options .pycg_max_iter ,
679687 using_ray = self .using_ray ,
680688 )
681- return pycg .build_call_graph_edges (symbol_table )
689+ return pycg .build_call_graph_edges (symbol_table , jedi_edges = jedi_edges )
682690 except PyCGExceptions .PyCGImportError as exc :
683691 logger .warning (f"PyCG not installed — level 2 edges will be Jedi-only: { exc } " )
684692 return []
0 commit comments