code/source: remove support for comparing Source with str

Cross-type comparisons like this are a bad idea. This isn't used.
This commit is contained in:
Ran Benita
2020-07-01 20:20:10 +03:00
parent 2b99bfbc60
commit a127a22d13
3 changed files with 10 additions and 12 deletions

View File

@@ -44,13 +44,10 @@ class Source:
else:
self.lines = deindent(getsource(obj).lines)
def __eq__(self, other):
try:
return self.lines == other.lines
except AttributeError:
if isinstance(other, str):
return str(self) == other
return False
def __eq__(self, other: object) -> bool:
if not isinstance(other, Source):
return NotImplemented
return self.lines == other.lines
# Ignore type because of https://github.com/python/mypy/issues/4266.
__hash__ = None # type: ignore