Use typing.Self throughout library

This commit is contained in:
Josh
2022-03-01 22:53:24 +10:00
committed by GitHub
parent a90e1824f4
commit 147948af9b
28 changed files with 212 additions and 191 deletions

View File

@ -23,7 +23,7 @@ DEALINGS IN THE SOFTWARE.
"""
from __future__ import annotations
from typing import Any, Dict, List, Optional, TypeVar, Union, overload, TYPE_CHECKING
from typing import Any, Dict, List, Optional, Union, TYPE_CHECKING
from .asset import Asset
from .permissions import Permissions
@ -37,6 +37,8 @@ __all__ = (
)
if TYPE_CHECKING:
from typing_extensions import Self
import datetime
from .types.role import (
Role as RolePayload,
@ -101,9 +103,6 @@ class RoleTags:
)
R = TypeVar('R', bound='Role')
class Role(Hashable):
"""Represents a Discord role in a :class:`Guild`.
@ -212,7 +211,7 @@ class Role(Hashable):
def __repr__(self) -> str:
return f'<Role id={self.id} name={self.name!r}>'
def __lt__(self: R, other: R) -> bool:
def __lt__(self, other: Any) -> bool:
if not isinstance(other, Role) or not isinstance(self, Role):
return NotImplemented
@ -233,16 +232,16 @@ class Role(Hashable):
return False
def __le__(self: R, other: R) -> bool:
def __le__(self, other: Any) -> bool:
r = Role.__lt__(other, self)
if r is NotImplemented:
return NotImplemented
return not r
def __gt__(self: R, other: R) -> bool:
def __gt__(self, other: Any) -> bool:
return Role.__lt__(other, self)
def __ge__(self: R, other: R) -> bool:
def __ge__(self, other: Any) -> bool:
r = Role.__lt__(self, other)
if r is NotImplemented:
return NotImplemented