Skip to content

Commit

Permalink
Commented out __hash__() and __eq__() methods from Literal. (#55)
Browse files Browse the repository at this point in the history
* Commented out __hash__() and __eq__() methods from Literal.

* Added a comment why __hash__() and __eq__() are commented out...
  • Loading branch information
jesper-friis authored Dec 16, 2022
1 parent 653cfb7 commit 3647ac1
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions tripper/literal.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,17 +101,23 @@ def __new__(
string.datatype = None
return string

def __hash__(self):
return hash((str(self), self.lang, self.datatype))

def __eq__(self, other):
if isinstance(other, Literal):
return (
str(self) == str(other)
and self.lang == other.lang
and self.datatype == other.datatype
)
return str(self) == str(other)
# These two methods are commeted out for now because they cause
# the DLite example/mapping/mappingfunc.py example to fail.
#
# It seems that these methods cause the datatype be changed to
# an "h" in some relations added by the add_function() method.

# def __hash__(self):
# return hash((str(self), self.lang, self.datatype))

# def __eq__(self, other):
# if isinstance(other, Literal):
# return (
# str(self) == str(other)
# and self.lang == other.lang
# and self.datatype == other.datatype
# )
# return str(self) == str(other)

def __repr__(self) -> str:
lang = f", lang='{self.lang}'" if self.lang else ""
Expand Down

0 comments on commit 3647ac1

Please # to comment.