aboutsummaryrefslogtreecommitdiffstats
path: root/slack/util.py
diff options
context:
space:
mode:
authorTrygve Aaberge <trygveaa@gmail.com>2024-02-19 19:06:25 +0100
committerTrygve Aaberge <trygveaa@gmail.com>2024-02-20 13:21:31 +0100
commit6e7ca7290d4a59398438e14623d9e71db7c7508d (patch)
treec791342ed3589cccc3f03500e06c8d312bf3c5f8 /slack/util.py
parentb10a3afb80b3477d9df91357b90bb949ac168f52 (diff)
downloadwee-slack-6e7ca7290d4a59398438e14623d9e71db7c7508d.tar.gz
Move completion code to a separate file
Diffstat (limited to 'slack/util.py')
-rw-r--r--slack/util.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/slack/util.py b/slack/util.py
index f7d16f5..19a6166 100644
--- a/slack/util.py
+++ b/slack/util.py
@@ -3,6 +3,7 @@ from __future__ import annotations
from functools import partial
from itertools import islice
from typing import (
+ TYPE_CHECKING,
Callable,
Iterable,
Iterator,
@@ -18,6 +19,9 @@ import weechat
from slack.shared import WeechatCallbackReturnType, shared
+if TYPE_CHECKING:
+ from slack.task import Future
+
T = TypeVar("T")
T2 = TypeVar("T2")
@@ -28,6 +32,10 @@ def get_callback_name(callback: Callable[..., WeechatCallbackReturnType]) -> str
return callback_id
+def get_resolved_futures(futures: Iterable[Future[T]]) -> List[T]:
+ return [future.result() for future in futures if future.done_with_result()]
+
+
def with_color(color: Optional[str], string: str, reset_color: str = "default"):
if color:
return f"{weechat.color(color)}{string}{weechat.color(reset_color)}"