joythief.core module¶
- class joythief.core.Matcher[source]¶
-
Abstract base class for all other matchers.
Defines the core requirements for any matcher:
Must be comparable for equality with anything.
Must have a sensible representation.
As
__eq__and__repr__are defined inMatcheritself, to provide core matcher behaviour, this abstract base class defines two equivalent abstract methods:compare()andrepresent(). You can write custom matchers by implementing these methods:import typing as tp from joythief.core import Matcher class IsWelcoming(Matcher[str]): def compare(self, other: tp.Any) -> bool: return other == "hello, world" def represent(self) -> str: return super().represent() # 'IsWelcoming()'