Skip to content

Commit

Permalink
fix: tweak pack and namespace equality
Browse files Browse the repository at this point in the history
  • Loading branch information
vberlier committed May 5, 2021
1 parent a3007a1 commit 5906fb2
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions beet/library/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,12 @@ def __setitem__(self, key: Any, value: Any):
self[type(value)][key] = value

def __eq__(self, other: Any) -> bool:
return self.extra == other.extra and all(
self[key] == other[key] for key in self.field_map
)
if type(self) == type(other) and not self.extra == other.extra:
return False
if isinstance(other, Mapping):
rhs: Mapping[Type[NamespaceFile], NamespaceContainer[NamespaceFile]] = other
return all(self[key] == rhs[key] for key in self.keys() | rhs.keys())
return NotImplemented

def __bool__(self) -> bool:
return any(self.values()) or bool(self.extra)
Expand Down Expand Up @@ -414,13 +417,14 @@ def __setitem__(self, key: str, value: Any):
NamespaceProxy[NamespaceFile](self, type(value))[key] = value

def __eq__(self, other: Any) -> bool:
if type(self) != type(other):
return NotImplemented
return (
self.name == other.name
and self.extra == other.extra
and all(self[key] == other[key] for key in self.keys() | other.keys())
)
if type(self) == type(other) and not (
self.name == other.name and self.extra == other.extra
):
return False
if isinstance(other, Mapping):
rhs: Mapping[str, Namespace] = other
return all(self[key] == rhs[key] for key in self.keys() | rhs.keys())
return NotImplemented

def __bool__(self) -> bool:
return any(self.values()) or self.extra.keys() > {"pack.mcmeta"}
Expand Down

0 comments on commit 5906fb2

Please sign in to comment.