From 45bc4bd0a05c85a7c6d113c516462bc2b0613e78 Mon Sep 17 00:00:00 2001 From: Chris Pressey Date: Tue, 12 Dec 2017 12:54:16 +0000 Subject: [PATCH] Tighten assumption when comparing LocationRefs. --- src/sixtypical/model.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/sixtypical/model.py b/src/sixtypical/model.py index 230ea0b..3488661 100644 --- a/src/sixtypical/model.py +++ b/src/sixtypical/model.py @@ -89,11 +89,12 @@ class LocationRef(Ref): def __eq__(self, other): # Ordinarily there will only be one ref with a given name, # but because we store the type in here and we want to treat - # these objects as immutable, we compare the types, too. - # Not sure if very wise. - return isinstance(other, self.__class__) and ( - other.name == self.name and other.type == self.type - ) + # these objects as immutable, we compare the types, too, + # just to be sure. + equal = isinstance(other, self.__class__) and other.name == self.name + if equal: + assert other.type == self.type + return equal def __hash__(self): return hash(self.name + str(self.type))