Check graph for violations of marimo semantics. Return a dict of errors in the graph, with an entry for each cell that is involved in an error.
(
graph: DirectedGraph,
)
| 17 | |
| 18 | |
| 19 | def check_for_errors( |
| 20 | graph: DirectedGraph, |
| 21 | ) -> dict[CellId_t, tuple[Error, ...]]: |
| 22 | """ |
| 23 | Check graph for violations of marimo semantics. |
| 24 | |
| 25 | Return a dict of errors in the graph, with an entry for each cell |
| 26 | that is involved in an error. |
| 27 | """ |
| 28 | multiple_definition_errors = check_for_multiple_definitions(graph) |
| 29 | cycle_errors = check_for_cycles(graph) |
| 30 | invalid_root_errors = check_for_invalid_root(graph) |
| 31 | |
| 32 | errors: dict[CellId_t, tuple[Error, ...]] = {} |
| 33 | for cid in set( |
| 34 | itertools.chain( |
| 35 | multiple_definition_errors.keys(), |
| 36 | cycle_errors.keys(), |
| 37 | invalid_root_errors.keys(), |
| 38 | ) |
| 39 | ): |
| 40 | errors[cid] = tuple( |
| 41 | itertools.chain( |
| 42 | multiple_definition_errors[cid], |
| 43 | cycle_errors[cid], |
| 44 | invalid_root_errors[cid], |
| 45 | ) |
| 46 | ) |
| 47 | return errors |
| 48 | |
| 49 | |
| 50 | def check_for_multiple_definitions( |
searching dependent graphs…