mirror of
https://github.com/Rapptz/discord.py.git
synced 2026-03-05 03:02:49 +00:00
[tasks] Add overloads
This commit is contained in:
@@ -37,6 +37,7 @@ from typing import (
|
|||||||
Type,
|
Type,
|
||||||
TypeVar,
|
TypeVar,
|
||||||
Union,
|
Union,
|
||||||
|
overload,
|
||||||
)
|
)
|
||||||
|
|
||||||
import aiohttp
|
import aiohttp
|
||||||
@@ -176,7 +177,7 @@ class Loop(Generic[LF]):
|
|||||||
if self.count is not None and self.count <= 0:
|
if self.count is not None and self.count <= 0:
|
||||||
raise ValueError('count must be greater than 0 or None.')
|
raise ValueError('count must be greater than 0 or None.')
|
||||||
|
|
||||||
self.change_interval(seconds=seconds, minutes=minutes, hours=hours, time=time)
|
self.change_interval(seconds=seconds, minutes=minutes, hours=hours, time=time) # type: ignore
|
||||||
self._last_iteration_failed = False
|
self._last_iteration_failed = False
|
||||||
self._last_iteration: datetime.datetime = MISSING
|
self._last_iteration: datetime.datetime = MISSING
|
||||||
self._next_iteration = None
|
self._next_iteration = None
|
||||||
@@ -710,6 +711,22 @@ class Loop(Generic[LF]):
|
|||||||
ret = sorted(set(ret)) # de-dupe and sort times
|
ret = sorted(set(ret)) # de-dupe and sort times
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
@overload
|
||||||
|
def change_interval(
|
||||||
|
self,
|
||||||
|
*,
|
||||||
|
seconds: float = 0,
|
||||||
|
minutes: float = 0,
|
||||||
|
hours: float = 0,
|
||||||
|
) -> None: ...
|
||||||
|
|
||||||
|
@overload
|
||||||
|
def change_interval(
|
||||||
|
self,
|
||||||
|
*,
|
||||||
|
time: Union[datetime.time, Sequence[datetime.time]],
|
||||||
|
) -> None: ...
|
||||||
|
|
||||||
def change_interval(
|
def change_interval(
|
||||||
self,
|
self,
|
||||||
*,
|
*,
|
||||||
@@ -777,6 +794,28 @@ class Loop(Generic[LF]):
|
|||||||
self._handle.recalculate(self._next_iteration)
|
self._handle.recalculate(self._next_iteration)
|
||||||
|
|
||||||
|
|
||||||
|
@overload
|
||||||
|
def loop(
|
||||||
|
*,
|
||||||
|
seconds: float = 0,
|
||||||
|
minutes: float = 0,
|
||||||
|
hours: float = 0,
|
||||||
|
count: Optional[int] = None,
|
||||||
|
reconnect: bool = True,
|
||||||
|
name: Optional[str] = None,
|
||||||
|
) -> Callable[[LF], Loop[LF]]: ...
|
||||||
|
|
||||||
|
|
||||||
|
@overload
|
||||||
|
def loop(
|
||||||
|
*,
|
||||||
|
time: Union[datetime.time, Sequence[datetime.time]],
|
||||||
|
count: Optional[int] = None,
|
||||||
|
reconnect: bool = True,
|
||||||
|
name: Optional[str] = None,
|
||||||
|
) -> Callable[[LF], Loop[LF]]: ...
|
||||||
|
|
||||||
|
|
||||||
def loop(
|
def loop(
|
||||||
*,
|
*,
|
||||||
seconds: float = MISSING,
|
seconds: float = MISSING,
|
||||||
|
|||||||
Reference in New Issue
Block a user