Return nodes matching any of *kinds*, optionally filtered by file. Args: kinds: List of node kind strings (e.g. ``["Function", "Test"]``). file_pattern: If provided, only nodes whose ``file_path`` contains *file_pattern* (SQL LIKE ``%pattern%``) are
(
self,
kinds: list[str],
file_pattern: str | None = None,
)
| 922 | return self._row_to_node(row) if row else None |
| 923 | |
| 924 | def get_nodes_by_kind( |
| 925 | self, |
| 926 | kinds: list[str], |
| 927 | file_pattern: str | None = None, |
| 928 | ) -> list[GraphNode]: |
| 929 | """Return nodes matching any of *kinds*, optionally filtered by file. |
| 930 | |
| 931 | Args: |
| 932 | kinds: List of node kind strings (e.g. ``["Function", "Test"]``). |
| 933 | file_pattern: If provided, only nodes whose ``file_path`` |
| 934 | contains *file_pattern* (SQL LIKE ``%pattern%``) are |
| 935 | returned. |
| 936 | """ |
| 937 | if not kinds: |
| 938 | return [] |
| 939 | placeholders = ",".join("?" for _ in kinds) |
| 940 | conditions = [f"kind IN ({placeholders})"] |
| 941 | params: list[str] = list(kinds) |
| 942 | if file_pattern: |
| 943 | conditions.append("file_path LIKE ?") |
| 944 | params.append(f"%{file_pattern}%") |
| 945 | where = " AND ".join(conditions) |
| 946 | rows = self._conn.execute( # nosec B608 |
| 947 | f"SELECT * FROM nodes WHERE {where}", params, |
| 948 | ).fetchall() |
| 949 | return [self._row_to_node(r) for r in rows] |
| 950 | |
| 951 | def count_flow_memberships(self, node_id: int) -> int: |
| 952 | """Return the number of flows a node participates in.""" |
no test coverage detected