Skip to content

Commit 76eb53c

Browse files
committed
🔧 MAINTAIN: Update to nbdime4
1 parent 4136098 commit 76eb53c

File tree

2 files changed

+19
-14
lines changed

2 files changed

+19
-14
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ dependencies = [
3131
"importlib-metadata~=6.0;python_version<'3.10'",
3232
"importlib-resources~=5.0;python_version<'3.9'",
3333
"nbclient~=0.5.10",
34-
"nbdime",
34+
"nbdime<5,>=4",
3535
"nbformat",
3636
"jsonschema",
3737
]

pytest_notebook/diffing.py

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
import copy
33
import operator
44
import re
5-
from typing import List, Sequence, Union
5+
from typing import List, Sequence
66

77
from nbdime.diff_format import DiffEntry, SequenceDiffBuilder
8+
from nbdime.diffing.config import DiffConfig
89
from nbdime.diffing.generic import default_differs, default_predicates, diff
910
from nbdime.diffing.notebooks import diff_attachments, diff_single_outputs
1011
from nbdime.prettyprint import PrettyPrintConfig, pretty_print_diff
@@ -19,23 +20,24 @@ def diff_sequence_simple(
1920
initial: Sequence,
2021
final: Sequence,
2122
path: str = "",
22-
predicates: Union[None, dict] = None,
23-
differs: Union[None, dict] = None,
23+
config: DiffConfig = None,
2424
) -> dict:
2525
"""Compute diff of two lists with configurable behaviour.
2626
2727
If the lists are of different lengths,
2828
we assume that items have been appended or removed from the end of the initial list.
2929
3030
"""
31+
if config is None:
32+
config = DiffConfig()
3133

32-
if predicates is None:
33-
predicates = default_predicates()
34-
if differs is None:
35-
differs = default_differs()
34+
if config.predicates is None:
35+
config.predicates = default_predicates()
36+
if config.differs is None:
37+
config.differs = default_differs()
3638

3739
subpath = "/".join((path, "*"))
38-
diffit = differs[subpath]
40+
diffit = config.differs[subpath]
3941

4042
di = SequenceDiffBuilder()
4143

@@ -48,7 +50,7 @@ def diff_sequence_simple(
4850
di.addrange(i, [bval])
4951
continue
5052

51-
cd = diffit(aval, bval, path=subpath, predicates=predicates, differs=differs)
53+
cd = diffit(aval, bval, path=subpath, config=config)
5254
if cd:
5355
di.patch(i, cd)
5456

@@ -75,10 +77,7 @@ def diff_notebooks(
7577
we shouldn't need to worry about insertions.
7678
7779
"""
78-
return diff(
79-
initial,
80-
final,
81-
path=initial_path,
80+
config = DiffConfig(
8281
predicates=defaultdict2(lambda: [operator.__eq__], {}),
8382
differs=defaultdict2(
8483
lambda: diff,
@@ -91,6 +90,12 @@ def diff_notebooks(
9190
},
9291
),
9392
)
93+
return diff(
94+
initial,
95+
final,
96+
path=initial_path,
97+
config=config,
98+
)
9499

95100

96101
R_IS_INT = re.compile(r"^[-+]?\d+$")

0 commit comments

Comments
 (0)