Skip to content

Commit

Permalink
fix: handle a check modifying the input fixtures (#243)
Browse files Browse the repository at this point in the history
Signed-off-by: Henry Schreiner <[email protected]>
  • Loading branch information
henryiii authored Aug 23, 2024
1 parent 51ca05f commit f789393
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/repo_review/processor.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
from __future__ import annotations

import copy
import dataclasses
import graphlib
import textwrap
import typing
import warnings
from collections.abc import Mapping, Set
from typing import Any, TypeVar

Expand Down Expand Up @@ -211,13 +213,18 @@ def process(

# Keep track of which checks have been completed
completed: dict[str, str | None] = {}
fixtures_copy = copy.deepcopy(fixtures)

# Run all the checks in topological order based on their dependencies
ts = graphlib.TopologicalSorter(graph)
for name in ts.static_order():
if all(completed.get(n, "") == "" for n in graph[name]):
result = apply_fixtures({"name": name, **fixtures}, tasks[name].check)
result = apply_fixtures({"name": name, **fixtures_copy}, tasks[name].check)
completed[name] = process_result_bool(result, tasks[name], name)
if fixtures != fixtures_copy:
fixtures_copy = copy.deepcopy(fixtures)
msg = f"{name} modified the input fixtures! Making a deepcopy to fix and continue."
warnings.warn(msg, stacklevel=1)
else:
completed[name] = None

Expand Down

0 comments on commit f789393

Please sign in to comment.