-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfacade_common.py
More file actions
41 lines (31 loc) · 1.04 KB
/
Copy pathfacade_common.py
File metadata and controls
41 lines (31 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
"""Shared helpers for language-specific re-export facade detectors."""
from __future__ import annotations
from collections.abc import Callable
def detect_reexport_facades_common(
graph: dict,
*,
is_facade_fn: Callable[[str], dict | None],
max_importers: int = 2,
) -> tuple[list[dict], int]:
"""Collect file-level re-export facades using a language detector callback."""
entries: list[dict] = []
total_checked = 0
for filepath, node in graph.items():
total_checked += 1
importer_count = node.get("importer_count", 0)
if importer_count > max_importers:
continue
result = is_facade_fn(filepath)
if not result:
continue
entries.append(
{
"file": filepath,
"loc": result["loc"],
"importers": importer_count,
"imports_from": result["imports_from"],
"kind": "file",
}
)
return entries, total_checked
__all__ = ["detect_reexport_facades_common"]