Skip to content

Commit f789393

Browse files
authored
fix: handle a check modifying the input fixtures (#243)
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
1 parent 51ca05f commit f789393

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/repo_review/processor.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
from __future__ import annotations
22

3+
import copy
34
import dataclasses
45
import graphlib
56
import textwrap
67
import typing
8+
import warnings
79
from collections.abc import Mapping, Set
810
from typing import Any, TypeVar
911

@@ -211,13 +213,18 @@ def process(
211213

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

215218
# Run all the checks in topological order based on their dependencies
216219
ts = graphlib.TopologicalSorter(graph)
217220
for name in ts.static_order():
218221
if all(completed.get(n, "") == "" for n in graph[name]):
219-
result = apply_fixtures({"name": name, **fixtures}, tasks[name].check)
222+
result = apply_fixtures({"name": name, **fixtures_copy}, tasks[name].check)
220223
completed[name] = process_result_bool(result, tasks[name], name)
224+
if fixtures != fixtures_copy:
225+
fixtures_copy = copy.deepcopy(fixtures)
226+
msg = f"{name} modified the input fixtures! Making a deepcopy to fix and continue."
227+
warnings.warn(msg, stacklevel=1)
221228
else:
222229
completed[name] = None
223230

0 commit comments

Comments
 (0)