@@ -128,7 +128,7 @@ Diff generation
128128
129129 The :class: `Differ ` class has this constructor:
130130
131- .. method :: __init__(linejunk=None, charjunk=None)
131+ .. method :: __init__(linejunk=None, charjunk=None, autojunk=True )
132132
133133 Optional keyword parameters *linejunk * and *charjunk * are for filter functions
134134 (or ``None ``):
@@ -147,6 +147,14 @@ Diff generation
147147 :meth: `~SequenceMatcher.find_longest_match ` method's *isjunk *
148148 parameter for an explanation.
149149
150+ Setting the optional *autojunk * argument to ``False `` will turn
151+ :ref: `automatic junk heuristic <difflib-junk >` off.
152+
153+ .. versionchanged :: 3.16
154+ Added keyword-only *autojunk * parameter.
155+
156+
157+
150158 :class: `Differ ` objects are used (deltas generated) via a single method:
151159
152160
@@ -161,6 +169,8 @@ Diff generation
161169 printed as-is via the :meth: `~io.IOBase.writelines ` method of a
162170 file-like object.
163171
172+
173+
164174.. class :: HtmlDiff
165175
166176 This class can be used to create an HTML table (or a complete HTML file
@@ -176,7 +186,7 @@ Diff generation
176186 The constructor for this class is:
177187
178188
179- .. method :: __init__(tabsize=8, wrapcolumn=None, linejunk=None, charjunk=IS_CHARACTER_JUNK)
189+ .. method :: __init__(tabsize=8, wrapcolumn=None, linejunk=None, charjunk=IS_CHARACTER_JUNK, *, autojunk=True )
180190
181191 Initializes instance of :class: `HtmlDiff `.
182192
@@ -187,8 +197,15 @@ Diff generation
187197 broken and wrapped, defaults to ``None `` where lines are not wrapped.
188198
189199 *linejunk * and *charjunk * are optional keyword arguments passed into :func: `ndiff `
190- (used by :class: `HtmlDiff ` to generate the side by side HTML differences). See
191- :func: `ndiff ` documentation for argument default values and descriptions.
200+ (used by :class: `HtmlDiff ` to generate the side by side HTML differences).
201+ See :func: `ndiff ` documentation for argument default values and descriptions.
202+
203+ Setting the optional *autojunk * argument to ``False `` will turn
204+ :ref: `automatic junk heuristic <difflib-junk >` off.
205+
206+ .. versionchanged :: 3.16
207+ Added keyword-only *autojunk * parameter.
208+
192209
193210 The following methods are public:
194211
@@ -231,7 +248,7 @@ Diff generation
231248
232249
233250
234- .. function :: context_diff(a, b, fromfile='', tofile='', fromfiledate='', tofiledate='', n=3, lineterm='\n')
251+ .. function :: context_diff(a, b, fromfile='', tofile='', fromfiledate='', tofiledate='', n=3, lineterm='\n', *, autojunk=True )
235252
236253 Compare *a * and *b * (lists of strings); return a delta (a :term: `generator `
237254 generating the delta lines) in context diff format.
@@ -277,8 +294,14 @@ Diff generation
277294
278295 See :ref: `difflib-interface ` for a more detailed example.
279296
297+ Setting the optional *autojunk * argument to ``False `` will turn
298+ :ref: `automatic junk heuristic <difflib-junk >` off.
299+
300+ .. versionchanged :: 3.16
301+ Added keyword-only *autojunk * parameter.
280302
281- .. function :: get_close_matches(word, possibilities, n=3, cutoff=0.6)
303+
304+ .. function :: get_close_matches(word, possibilities, n=3, cutoff=0.6, *, autojunk=True)
282305
283306 Return a list of the best "good enough" matches. *word * is a sequence for which
284307 close matches are desired (typically a string), and *possibilities * is a list of
@@ -290,6 +313,9 @@ Diff generation
290313 Optional argument *cutoff * (default ``0.6 ``) is a float in the range [0, 1].
291314 Possibilities that don't score at least that similar to *word * are ignored.
292315
316+ Setting the optional *autojunk * argument to ``False `` will turn
317+ :ref: `automatic junk heuristic <difflib-junk >` off.
318+
293319 The best (no more than *n *) matches among the possibilities are returned in a
294320 list, sorted by similarity score, most similar first.
295321
@@ -303,8 +329,11 @@ Diff generation
303329 >>> get_close_matches(' accept' , keyword.kwlist)
304330 ['except']
305331
332+ .. versionchanged :: 3.16
333+ Added keyword-only *autojunk * parameter.
334+
306335
307- .. function :: ndiff(a, b, linejunk=None, charjunk=IS_CHARACTER_JUNK)
336+ .. function :: ndiff(a, b, linejunk=None, charjunk=IS_CHARACTER_JUNK, *, autojunk=True )
308337
309338 Compare *a * and *b * (lists of strings); return a :class: `Differ `\ -style
310339 delta (a :term: `generator ` generating the delta lines).
@@ -325,6 +354,11 @@ Diff generation
325354 function :func: `IS_CHARACTER_JUNK `, which filters out whitespace characters (a
326355 blank or tab; it's a bad idea to include newline in this!).
327356
357+ Setting the optional *autojunk * argument to ``False `` will turn
358+ :ref: `automatic junk heuristic <difflib-junk >` off.
359+
360+ Example:
361+
328362 >>> diff = ndiff(' one\n two\n three\n ' .splitlines(keepends = True ),
329363 ... ' ore\n tree\n emu\n ' .splitlines(keepends = True ))
330364 >>> print (' ' .join(diff), end = " " )
@@ -338,6 +372,9 @@ Diff generation
338372 + tree
339373 + emu
340374
375+ .. versionchanged :: 3.16
376+ Added keyword-only *autojunk * parameter.
377+
341378
342379.. function :: restore(sequence, which)
343380
@@ -362,7 +399,7 @@ Diff generation
362399 emu
363400
364401
365- .. function :: unified_diff(a, b, fromfile='', tofile='', fromfiledate='', tofiledate='', n=3, lineterm='\n', *, color=False)
402+ .. function :: unified_diff(a, b, fromfile='', tofile='', fromfiledate='', tofiledate='', n=3, lineterm='\n', *, autojunk=True, color=False)
366403
367404 Compare *a * and *b * (lists of strings); return a delta (a :term: `generator `
368405 generating the delta lines) in unified diff format.
@@ -410,6 +447,12 @@ Diff generation
410447 .. versionchanged :: 3.15
411448 Added the *color * parameter.
412449
450+ Setting the optional *autojunk * argument to ``False `` will turn
451+ :ref: `automatic junk heuristic <difflib-junk >` off.
452+
453+ .. versionchanged :: 3.16
454+ Added keyword-only *autojunk * parameter.
455+
413456
414457.. function :: diff_bytes(dfunc, a, b, fromfile=b'', tofile=b'', fromfiledate=b'', tofiledate=b'', n=3, lineterm=b'\n')
415458
0 commit comments