Skip to content

Commit

Permalink
fix: Fix comparing names with strings
Browse files Browse the repository at this point in the history
Issue #114: #114
  • Loading branch information
pawamoy committed Nov 30, 2022
1 parent 0ed9c36 commit 37ae0a2
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/griffe/expressions.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,12 @@ def __init__(self, source: str, full: str | Callable) -> None:
self._full = ""
self._resolver = full

def __eq__(self, other: Name | Expression) -> bool: # type: ignore[override]
return self.full == other.full # noqa: WPS437
def __eq__(self, other: Any) -> bool:
if isinstance(other, str):
return self.full == other or self.brief == other
if isinstance(other, (Name, Expression)):
return self.full == other.full # noqa: WPS437
raise NotImplementedError(f"uncomparable types: {type(self)} and {type(other)}")

def __repr__(self) -> str:
return f"Name(source={self.source!r}, full={self.full!r})"
Expand Down

0 comments on commit 37ae0a2

Please # to comment.