-
-
Notifications
You must be signed in to change notification settings - Fork 169
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
fix #526 #550
Merged
Merged
fix #526 #550
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -436,6 +436,25 @@ def __repr__(self): | |
subs = ', '.join(str(it) for it in self.subcomponents) | ||
return f"{self.name or type(self).__name__}({dict(self)}{', ' + subs if subs else ''})" | ||
|
||
def __eq__(self, other): | ||
if not len(self.subcomponents) == len(other.subcomponents): | ||
return False | ||
|
||
properties_equal = super().__eq__(other) | ||
if not properties_equal: | ||
return False | ||
|
||
# The subcomponents might not be in the same order, | ||
# neither there's a natural key we can sort the subcomponents by nor | ||
# are the subcomponent types hashable, so we cant put them in a set to | ||
# check for set equivalence. We have to iterate over the subcomponents | ||
# and look for each of them in the list. | ||
for subcomponent in self.subcomponents: | ||
if subcomponent not in other.subcomponents: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is a subset test. a == b does not imply b == a.
jacadzaca marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return False | ||
|
||
return True | ||
|
||
|
||
####################################### | ||
# components defined in RFC 5545 | ||
|
18 changes: 18 additions & 0 deletions
18
src/icalendar/tests/calendars/issue_526_calendar_with_different_events.ics
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
BEGIN:VCALENDAR | ||
VERSION:2.0 | ||
PRODID:icalendar-2023 | ||
BEGIN:VEVENT | ||
UID:ical-jacadzaca-3 | ||
SUMMARY: Some very different event ':' | ||
DTSTART;TZID="Western/Central Europe";VALUE=DATE-TIME:20211101T160000 | ||
DTEND;TZID="Western/Central Europe";VALUE=DATE-TIME:20211101T163000 | ||
DTSTAMP:20211004T150245Z | ||
END:VEVENT | ||
BEGIN:VEVENT | ||
UID:ical-jacadzaca-4 | ||
SUMMARY: Some very different other event | ||
DTSTART;TZID="Western/Central Europe";VALUE=DATE-TIME:20211101T164000 | ||
DTEND;TZID="Western/Central Europe";VALUE=DATE-TIME:20211101T165000 | ||
DTSTAMP:20211004T150245Z | ||
END:VEVENT | ||
END:VCALENDAR |
11 changes: 11 additions & 0 deletions
11
src/icalendar/tests/calendars/issue_526_calendar_with_event_subset.ics
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
BEGIN:VCALENDAR | ||
VERSION:2.0 | ||
PRODID:icalendar-2023 | ||
BEGIN:VEVENT | ||
UID:1 | ||
SUMMARY: Some event ':' | ||
DTSTART;TZID="Western/Central Europe";VALUE=DATE-TIME:20211101T160000 | ||
DTEND;TZID="Western/Central Europe";VALUE=DATE-TIME:20211101T163000 | ||
DTSTAMP:20211004T150245Z | ||
END:VEVENT | ||
END:VCALENDAR |
18 changes: 18 additions & 0 deletions
18
src/icalendar/tests/calendars/issue_526_calendar_with_events.ics
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
BEGIN:VCALENDAR | ||
VERSION:2.0 | ||
PRODID:icalendar-2023 | ||
BEGIN:VEVENT | ||
UID:1 | ||
SUMMARY: Some event ':' | ||
DTSTART;TZID="Western/Central Europe";VALUE=DATE-TIME:20211101T160000 | ||
DTEND;TZID="Western/Central Europe";VALUE=DATE-TIME:20211101T163000 | ||
DTSTAMP:20211004T150245Z | ||
END:VEVENT | ||
BEGIN:VEVENT | ||
UID:2 | ||
SUMMARY: Some other event | ||
DTSTART;TZID="Western/Central Europe";VALUE=DATE-TIME:20211101T164000 | ||
DTEND;TZID="Western/Central Europe";VALUE=DATE-TIME:20211101T165000 | ||
DTSTAMP:20211004T150245Z | ||
END:VEVENT | ||
END:VCALENDAR |
18 changes: 18 additions & 0 deletions
18
src/icalendar/tests/calendars/issue_526_calendar_with_shuffeled_events.ics
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
BEGIN:VCALENDAR | ||
VERSION:2.0 | ||
PRODID:icalendar-2023 | ||
BEGIN:VEVENT | ||
UID:2 | ||
SUMMARY: Some other event | ||
DTSTART;TZID="Western/Central Europe";VALUE=DATE-TIME:20211101T164000 | ||
DTEND;TZID="Western/Central Europe";VALUE=DATE-TIME:20211101T165000 | ||
DTSTAMP:20211004T150245Z | ||
END:VEVENT | ||
BEGIN:VEVENT | ||
UID:1 | ||
SUMMARY: Some event ':' | ||
DTSTART;TZID="Western/Central Europe";VALUE=DATE-TIME:20211101T160000 | ||
DTEND;TZID="Western/Central Europe";VALUE=DATE-TIME:20211101T163000 | ||
DTSTAMP:20211004T150245Z | ||
END:VEVENT | ||
END:VCALENDAR |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a rule, overriding eq should also override hash. But I think, as long as the equality gets reduced, equality still implies hash equality.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that implementing a
__hash__
for sub-class of CaselessDict is not straightforward as per [this](https://github.com/collective/icalendar/pull/391/files#r957502946}