Skip to content
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 union of frozendict for python implementation #89

Merged
merged 2 commits into from
Nov 18, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
8 changes: 1 addition & 7 deletions src/frozendict/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,13 +217,7 @@ def frozendict_or(self, other, *args, **kwargs):

return self.__class__(res)



try:
frozendict.__or__
except AttributeError:
frozendict.__or__ = frozendict_or

frozendict.__or__ = frozendict_or
frozendict.__ior__ = frozendict.__or__

try:
Expand Down
2 changes: 2 additions & 0 deletions test/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ def test_iter(self, fd):

def test_sum(self, fd, fd_dict, fd_dict_sabina):
new_fd = fd | fd_dict_sabina
assert type(new_fd) is self.FrozendictClass
new_dict = dict(fd_dict)
new_dict.update(fd_dict_sabina)
assert new_fd == new_dict
Expand All @@ -178,6 +179,7 @@ def test_union(self, fd_dict, fd_sabina):
new_fd = self.FrozendictClass(fd_dict)
id_fd = id(new_fd)
new_fd |= fd_sabina
assert type(new_fd) is self.FrozendictClass
assert id_fd != id(new_fd)
new_dict = dict(fd_dict)
new_dict.update(fd_sabina)
Expand Down
Loading