diff --git a/src/griffe/expressions.py b/src/griffe/expressions.py index b9490e3a..af7baa5b 100644 --- a/src/griffe/expressions.py +++ b/src/griffe/expressions.py @@ -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})"