aboutsummaryrefslogtreecommitdiff
path: root/discord
diff options
context:
space:
mode:
authorRapptz <[email protected]>2021-05-05 23:23:30 -0400
committerRapptz <[email protected]>2021-05-05 23:33:11 -0400
commit7bad27d215c3958c157cd7a36fe5fdd2f42a8d68 (patch)
tree214b4bd253177588e34b77569cfede81f364f01e /discord
parentFix typings in message.py (diff)
downloaddiscord.py-7bad27d215c3958c157cd7a36fe5fdd2f42a8d68.tar.xz
discord.py-7bad27d215c3958c157cd7a36fe5fdd2f42a8d68.zip
Fix SnowflakeList typings
Diffstat (limited to 'discord')
-rw-r--r--discord/utils.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/discord/utils.py b/discord/utils.py
index 07229312..d4f0a48c 100644
--- a/discord/utils.py
+++ b/discord/utils.py
@@ -155,6 +155,7 @@ class CachedSlotProperty(Generic[T, T_co]):
setattr(instance, self.name, value)
return value
+
class classproperty(Generic[T_co]):
def __init__(self, fget: Callable[[Any], T_co]) -> None:
self.fget = fget
@@ -165,6 +166,7 @@ class classproperty(Generic[T_co]):
def __set__(self, instance, value) -> None:
raise AttributeError('cannot set attribute')
+
def cached_slot_property(name: str) -> Callable[[Callable[[T], T_co]], CachedSlotProperty[T, T_co]]:
def decorator(func: Callable[[T], T_co]) -> CachedSlotProperty[T, T_co]:
return CachedSlotProperty(name, func)
@@ -560,7 +562,20 @@ class SnowflakeList(array.array):
__slots__ = ()
- def __new__(cls, data: Sequence[int], *, is_sorted: bool = False):
+ if TYPE_CHECKING:
+
+ @overload
+ def __init__(self, data: Iterable[int], *, is_sorted: Literal[False] = False):
+ ...
+
+ @overload
+ def __init__(self, data: Sequence[int], *, is_sorted: Literal[True]):
+ ...
+
+ def __init__(self, data: Union[Sequence[int], Iterable[int]], *, is_sorted: bool = False):
+ ...
+
+ def __new__(cls, data: Union[Sequence[int], Iterable[int]], *, is_sorted: bool = False):
return array.array.__new__(cls, 'Q', data if is_sorted else sorted(data)) # type: ignore
def add(self, element: int) -> None: