Skip to content

Commit 6261282

Browse files
committed
black
1 parent 16599a0 commit 6261282

File tree

2 files changed

+25
-18
lines changed

2 files changed

+25
-18
lines changed

patchdiff/__init__.py

+24-13
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,35 @@ def dist(i, j):
1616
if i > 0:
1717
base = dist(i - 1, j)
1818
op = {"op": "remove", "idx": i - 1}
19-
paths.append({
20-
"ops": base["ops"] + [op],
21-
"cost": base["cost"] + 1,
22-
})
19+
paths.append(
20+
{
21+
"ops": base["ops"] + [op],
22+
"cost": base["cost"] + 1,
23+
}
24+
)
2325
if j > 0:
2426
base = dist(i, j - 1)
2527
op = {"op": "add", "idx": j - 1, "value": output[j - 1]}
26-
paths.append({
27-
"ops": base["ops"] + [op],
28-
"cost": base["cost"] + 1,
29-
})
28+
paths.append(
29+
{
30+
"ops": base["ops"] + [op],
31+
"cost": base["cost"] + 1,
32+
}
33+
)
3034
if i > 0 and j > 0:
3135
base = dist(i - 1, j - 1)
32-
op = {"op": "replace", "idx": i - 1, "original": input[i - 1], "value": output[j - 1]}
33-
paths.append({
34-
"ops": base["ops"] + [op],
35-
"cost": base["cost"] + 1,
36-
})
36+
op = {
37+
"op": "replace",
38+
"idx": i - 1,
39+
"original": input[i - 1],
40+
"value": output[j - 1],
41+
}
42+
paths.append(
43+
{
44+
"ops": base["ops"] + [op],
45+
"cost": base["cost"] + 1,
46+
}
47+
)
3748
step = min(paths, key=lambda a: a["cost"])
3849
memory[(i, j)] = step
3950
return memory[(i, j)]

tests/test_all.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,7 @@ def test_dicts():
1717
"a": 5,
1818
"b": 6,
1919
}
20-
b = {
21-
"a": 3,
22-
"b": 6,
23-
"c": 7
24-
}
20+
b = {"a": 3, "b": 6, "c": 7}
2521
ops = diff(a, b)
2622

2723
assert len(ops) == 2

0 commit comments

Comments
 (0)