Skip to content

Commit

Permalink
remove deprecated text_diff_ctx opt from diff func
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-mixas committed Aug 20, 2023
1 parent c1a4e7d commit 0ec6c2e
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 23 deletions.
14 changes: 1 addition & 13 deletions nested_diff/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

"""Recursive diff and patch for nested structures."""

from warnings import warn

import nested_diff.handlers

__all__ = ['Differ', 'Iterator', 'Patcher', 'diff', 'patch']
Expand Down Expand Up @@ -313,16 +311,13 @@ def set_handler(self, handler):
self._iters_by_ext[handler.extension_id] = handler.iterate_diff


def diff(a, b, extra_handlers=(), text_diff_ctx=-1, **kwargs):
def diff(a, b, extra_handlers=(), **kwargs):
"""Calculate diff for two objects.
Args:
a: First object to diff.
b: Second object to diff.
extra_handlers: List of additional type handlers.
text_diff_ctx: Amount of context lines for text (multiline strings)
diffs. Disabled entirely when value is negative. This opt is
deprecated and should be avoided.
kwargs: Passed to Differ's constructor as is.
Returns:
Expand All @@ -334,13 +329,6 @@ def diff(a, b, extra_handlers=(), text_diff_ctx=-1, **kwargs):
for handler in extra_handlers:
differ.set_handler(handler)

if text_diff_ctx >= 0:
warn('`text_diff_ctx` opt is deprecated and will be removed soon',
DeprecationWarning, stacklevel=2)

differ.set_handler(nested_diff.handlers.TextHandler(
context=text_diff_ctx))

return differ.diff(a, b)[1]


Expand Down
10 changes: 0 additions & 10 deletions tests/test_diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,3 @@ def test_text_diff_func_extra_handlers_opt():
got = diff(a, b, extra_handlers=[handlers.TextHandler(context=3)])

assert got == expected


def test_text_diff_func_text_diff_ctx_opt():
a = ['a']
b = ['a\nb']

expected = {'D': [{'D': [{'I': [0, 1, 0, 2]}, {'U': 'a'}, {'A': 'b'}], 'E': 5}]}
got = diff(a, b, text_diff_ctx=3)

assert got == expected

0 comments on commit 0ec6c2e

Please sign in to comment.