Skip to content

Commit 93e4c19

Browse files
style(pre-commit): auto fixes from pre-commit.com hooks
1 parent daab987 commit 93e4c19

File tree

1 file changed

+24
-8
lines changed

1 file changed

+24
-8
lines changed

discord/ext/tasks/__init__.py

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
import sys
3333
import traceback
3434
from collections.abc import Sequence
35-
from typing import Any, Awaitable, Callable, Generic, TypeVar, cast
35+
from typing import Any, Awaitable, Callable, Generic, TypeVar
3636

3737
import aiohttp
3838

@@ -68,7 +68,12 @@ def is_imaginary(dt: datetime.datetime) -> bool:
6868

6969
tz = dt.tzinfo
7070
dt = dt.replace(tzinfo=None)
71-
roundtrip = dt.replace(tzinfo=tz).astimezone(datetime.timezone.utc).astimezone(tz).replace(tzinfo=None)
71+
roundtrip = (
72+
dt.replace(tzinfo=tz)
73+
.astimezone(datetime.timezone.utc)
74+
.astimezone(tz)
75+
.replace(tzinfo=None)
76+
)
7277
return dt != roundtrip
7378

7479

@@ -91,7 +96,9 @@ def _safe_result(future: asyncio.Future) -> None:
9196
def recalculate(self, dt: datetime.datetime) -> None:
9297
self.handle.cancel()
9398
relative_delta = discord.utils.compute_timedelta(dt)
94-
self.handle = self.loop.call_later(relative_delta, self._safe_result, self.future)
99+
self.handle = self.loop.call_later(
100+
relative_delta, self._safe_result, self.future
101+
)
95102

96103
def wait(self) -> asyncio.Future[Any]:
97104
return self.future
@@ -133,7 +140,11 @@ def __init__(
133140

134141
self.loop = loop
135142

136-
self.name: str = f'pycord-ext-task ({id(self):#x}): {coro.__qualname__}' if name in (None, MISSING) else name
143+
self.name: str = (
144+
f"pycord-ext-task ({id(self):#x}): {coro.__qualname__}"
145+
if name in (None, MISSING)
146+
else name
147+
)
137148
self.count: int | None = count
138149
self._current_loop = 0
139150
self._handle: SleepHandle = MISSING
@@ -214,9 +225,12 @@ async def _loop(self, *args: Any, **kwargs: Any) -> None:
214225
self._last_iteration = self._next_iteration
215226
self._next_iteration = self._get_next_sleep_time()
216227

217-
while self._expl_time() and self._next_iteration <= self._last_iteration:
228+
while (
229+
self._expl_time()
230+
and self._next_iteration <= self._last_iteration
231+
):
218232
_log.warning(
219-
'Task %s woke up at %s, which was before expected (%s). Sleeping again to fix it...',
233+
"Task %s woke up at %s, which was before expected (%s). Sleeping again to fix it...",
220234
self.coro.__name__,
221235
discord.utils.utcnow(),
222236
self._next_iteration,
@@ -233,7 +247,7 @@ async def _loop(self, *args: Any, **kwargs: Any) -> None:
233247

234248
delay = backoff.delay()
235249
_log.warning(
236-
'Received an exception which was in the valid exception set. Task will run again in %s.2f seconds',
250+
"Received an exception which was in the valid exception set. Task will run again in %s.2f seconds",
237251
self.coro.__name__,
238252
delay,
239253
exc_info=exc,
@@ -626,7 +640,9 @@ def error(self, coro: ET) -> ET:
626640
self._error = coro # type: ignore
627641
return coro
628642

629-
def _get_next_sleep_time(self, now: datetime.datetime = MISSING) -> datetime.datetime:
643+
def _get_next_sleep_time(
644+
self, now: datetime.datetime = MISSING
645+
) -> datetime.datetime:
630646
if self._sleep is not MISSING:
631647
return self._last_iteration + datetime.timedelta(seconds=self._sleep)
632648

0 commit comments

Comments
 (0)