22import copy
33import operator
44import re
5- from typing import List , Sequence , Union
5+ from typing import List , Sequence
66
77from nbdime .diff_format import DiffEntry , SequenceDiffBuilder
8+ from nbdime .diffing .config import DiffConfig
89from nbdime .diffing .generic import default_differs , default_predicates , diff
910from nbdime .diffing .notebooks import diff_attachments , diff_single_outputs
1011from 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
96101R_IS_INT = re .compile (r"^[-+]?\d+$" )
0 commit comments