diff options
| author | Rapptz <[email protected]> | 2021-05-29 02:44:31 -0400 |
|---|---|---|
| committer | Rapptz <[email protected]> | 2021-05-29 02:44:31 -0400 |
| commit | 5a9cbc967bf9c669caec02a8090bc9f52ab77187 (patch) | |
| tree | 78f67a90d32f5515f9f5bbad1bb2df7d35a65647 /discord | |
| parent | Fix type errors with required keys in the integration types (diff) | |
| download | discord.py-5a9cbc967bf9c669caec02a8090bc9f52ab77187.tar.xz discord.py-5a9cbc967bf9c669caec02a8090bc9f52ab77187.zip | |
Typehint mixins
Diffstat (limited to 'discord')
| -rw-r--r-- | discord/mixins.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/discord/mixins.py b/discord/mixins.py index f373ecf8..3eca279f 100644 --- a/discord/mixins.py +++ b/discord/mixins.py @@ -22,18 +22,24 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ +from typing import TypeVar + __all__ = ( 'EqualityComparable', 'Hashable', ) +E = TypeVar('E', bound='EqualityComparable') + class EqualityComparable: __slots__ = () - def __eq__(self, other): + id: int + + def __eq__(self: E, other: E) -> bool: return isinstance(other, self.__class__) and other.id == self.id - def __ne__(self, other): + def __ne__(self: E, other: E) -> bool: if isinstance(other, self.__class__): return other.id != self.id return True @@ -41,5 +47,5 @@ class EqualityComparable: class Hashable(EqualityComparable): __slots__ = () - def __hash__(self): + def __hash__(self) -> int: return self.id >> 22 |