Skip to content

Commit

Permalink
Use unresolved values for comparison and hash
Browse files Browse the repository at this point in the history
  • Loading branch information
Flamefire committed Apr 17, 2020
1 parent 66df965 commit 1b74197
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions easybuild/framework/easyconfig/easyconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -1685,11 +1685,14 @@ def get(self, key, default=None, resolve=True):
# see also https://docs.python.org/2/reference/datamodel.html#object.__eq__
def __eq__(self, ec):
"""Is this EasyConfig instance equivalent to the provided one?"""
return self.asdict() == ec.asdict()
# Compare raw values to check that templates used are the same
with disable_templating(self):
with disable_templating(ec):
return self.asdict() == ec.asdict()

def __ne__(self, ec):
"""Is this EasyConfig instance equivalent to the provided one?"""
return self.asdict() != ec.asdict()
return not self == ec

def __hash__(self):
"""Return hash value for a hashable representation of this EasyConfig instance."""
Expand All @@ -1702,8 +1705,9 @@ def make_hashable(val):
return val

lst = []
for (key, val) in sorted(self.asdict().items()):
lst.append((key, make_hashable(val)))
with disable_templating(self):
for (key, val) in sorted(self.asdict().items()):
lst.append((key, make_hashable(val)))

# a list is not hashable, but a tuple is
return hash(tuple(lst))
Expand Down

0 comments on commit 1b74197

Please sign in to comment.