Skip to content

Fix broken DeepDiff for dateutils.rrules (#355) #356

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Dec 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,4 @@ Authors in order of the timeline of their contributions:
- Mikhail Khviyuzov [mskhviyu](https://github.com/mskhviyu) for Exclude obj callback strict.
- [dtorres-sf](https://github.com/dtorres-sf) for the fix for diffing using iterable_compare_func with nested objects.
- [Enric Pou](https://github.com/epou) for bug fix of ValueError when using Decimal 0.x
- [Uwe Fladrich] (https://github.com/uwefladrich) for fixing bug when diff'ing non-sequence iterables
10 changes: 8 additions & 2 deletions deepdiff/diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from enum import Enum
from copy import deepcopy
from math import isclose as is_close
from collections.abc import Mapping, Iterable
from collections.abc import Mapping, Iterable, Sequence
from collections import defaultdict
from itertools import zip_longest
from ordered_set import OrderedSet
Expand Down Expand Up @@ -727,7 +727,13 @@ def _diff_iterable_in_order(self, level, parents_ids=frozenset(), _original_type
else:
child_relationship_class = NonSubscriptableIterableRelationship

if self._all_values_basic_hashable(level.t1) and self._all_values_basic_hashable(level.t2) and self.iterable_compare_func is None:
if (
isinstance(level.t1, Sequence)
and isinstance(level.t2, Sequence)
and self._all_values_basic_hashable(level.t1)
and self._all_values_basic_hashable(level.t2)
and self.iterable_compare_func is None
):
local_tree_pass = TreeResult()
self._diff_ordered_iterable_by_difflib(
level,
Expand Down
1 change: 1 addition & 0 deletions requirements-dev-3.7.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ ipdb==0.13.9
numpy==1.21.6
pytest==7.1.2
python-dotenv==0.20.0
python-dateutil==2.8.2
1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ watchdog==2.1.9
Sphinx==5.1.1
sphinx-sitemap==2.2.0
flake8==5.0.4
python-dateutil==2.8.2
31 changes: 31 additions & 0 deletions tests/test_diff_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -1713,3 +1713,34 @@ def __thing2(self):
}

assert expected2 == diff2

def test_diffs_rrules(self):

from dateutil.rrule import MONTHLY, rrule

d = DeepDiff(
rrule(freq=MONTHLY, count=5, dtstart=datetime.datetime(2014, 12, 31)),
rrule(freq=MONTHLY, count=4, dtstart=datetime.datetime(2011, 12, 31)),
)

assert d == {
"values_changed": {
"root[0]": {
"new_value": datetime.datetime(2011, 12, 31, 0, 0),
"old_value": datetime.datetime(2014, 12, 31, 0, 0),
},
"root[1]": {
"new_value": datetime.datetime(2012, 1, 31, 0, 0),
"old_value": datetime.datetime(2015, 1, 31, 0, 0),
},
"root[2]": {
"new_value": datetime.datetime(2012, 3, 31, 0, 0),
"old_value": datetime.datetime(2015, 3, 31, 0, 0),
},
"root[3]": {
"new_value": datetime.datetime(2012, 5, 31, 0, 0),
"old_value": datetime.datetime(2015, 5, 31, 0, 0),
},
},
"iterable_item_removed": {"root[4]": datetime.datetime(2015, 7, 31, 0, 0)},
}