Compute human-readable signatures for nodes that lack one.
(
store: GraphStore,
result: dict[str, Any],
warnings: list[str],
)
| 53 | |
| 54 | |
| 55 | def _compute_signatures( |
| 56 | store: GraphStore, |
| 57 | result: dict[str, Any], |
| 58 | warnings: list[str], |
| 59 | ) -> None: |
| 60 | """Compute human-readable signatures for nodes that lack one.""" |
| 61 | try: |
| 62 | rows = store.get_nodes_without_signature() |
| 63 | for row in rows: |
| 64 | node_id, name, kind, params, ret = ( |
| 65 | row[0], |
| 66 | row[1], |
| 67 | row[2], |
| 68 | row[3], |
| 69 | row[4], |
| 70 | ) |
| 71 | if kind in ("Function", "Test"): |
| 72 | sig = f"def {name}({params or ''})" |
| 73 | if ret: |
| 74 | sig += f" -> {ret}" |
| 75 | elif kind == "Class": |
| 76 | sig = f"class {name}" |
| 77 | else: |
| 78 | sig = name |
| 79 | store.update_node_signature(node_id, sig[:512]) |
| 80 | store.commit() |
| 81 | result["signatures_computed"] = len(rows) |
| 82 | except (sqlite3.OperationalError, TypeError, KeyError) as e: |
| 83 | logger.warning("Signature computation failed: %s", e) |
| 84 | warnings.append(f"Signature computation failed: {type(e).__name__}: {e}") |
| 85 | |
| 86 | |
| 87 | def _rebuild_fts_index( |
no test coverage detected