aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTrygve Aaberge <trygveaa@gmail.com>2023-01-29 16:58:45 +0100
committerTrygve Aaberge <trygveaa@gmail.com>2024-02-18 11:32:53 +0100
commite892fca6a2140057b155bf623a5dc11ea41e2577 (patch)
tree0317dc38ca3936a542677095e9286e3b8022e3cc
parentb28acc3d7d14acfc5c8244118a4e57909d88e752 (diff)
downloadwee-slack-e892fca6a2140057b155bf623a5dc11ea41e2577.tar.gz
Fix some mypy specific type issues
-rw-r--r--slack/commands.py11
-rw-r--r--slack/http.py6
-rw-r--r--slack/slack_api.py20
-rw-r--r--typings/slack_api/slack_conversations_info.pyi4
-rw-r--r--typings/slack_api/slack_users_conversations.pyi4
-rw-r--r--typings/slack_api/slack_users_info.pyi4
6 files changed, 28 insertions, 21 deletions
diff --git a/slack/commands.py b/slack/commands.py
index b4bb1b5..c60b420 100644
--- a/slack/commands.py
+++ b/slack/commands.py
@@ -53,8 +53,13 @@ class Command:
def weechat_command(
completion: str = "", min_args: int = 0, slack_buffer_required: bool = False
-):
- def decorator(f: Callable[[str, List[str], Dict[str, Optional[str]]], None]):
+) -> Callable[
+ [Callable[[str, List[str], Dict[str, Optional[str]]], None]],
+ Callable[[str, str], None],
+]:
+ def decorator(
+ f: Callable[[str, List[str], Dict[str, Optional[str]]], None]
+ ) -> Callable[[str, str], None]:
cmd = removeprefix(f.__name__, "command_").replace("_", " ")
top_level = " " not in cmd
@@ -367,7 +372,7 @@ async def complete_user_next(
complete_input(conversation, query)
-def complete_previous(conversation: SlackConversation, query: str):
+def complete_previous(conversation: SlackConversation, query: str) -> int:
if conversation.completion_context == "ACTIVE_COMPLETION":
conversation.completion_index -= 1
if conversation.completion_index < 0:
diff --git a/slack/http.py b/slack/http.py
index 9347842..73a3303 100644
--- a/slack/http.py
+++ b/slack/http.py
@@ -3,7 +3,7 @@ from __future__ import annotations
import os
import resource
from io import StringIO
-from typing import Dict
+from typing import Dict, Tuple
import weechat
@@ -19,7 +19,9 @@ def available_file_descriptors():
return max_file_descriptors - num_current_file_descriptors
-async def hook_process_hashtable(command: str, options: Dict[str, str], timeout: int):
+async def hook_process_hashtable(
+ command: str, options: Dict[str, str], timeout: int
+) -> Tuple[str, int, str, str]:
future = FutureProcess()
log(
LogLevel.DEBUG,
diff --git a/slack/slack_api.py b/slack/slack_api.py
index fd75277..1404e81 100644
--- a/slack/slack_api.py
+++ b/slack/slack_api.py
@@ -91,7 +91,7 @@ class SlackApi:
async def fetch_conversations_history(self, conversation: SlackConversation):
method = "conversations.history"
- params = {"channel": conversation.id}
+ params: Params = {"channel": conversation.id}
response: SlackConversationsHistoryResponse = await self._fetch(method, params)
if response["ok"] is False:
raise SlackApiError(self.workspace, method, response, params)
@@ -99,7 +99,7 @@ class SlackApi:
async def fetch_conversations_info(self, conversation_id: str):
method = "conversations.info"
- params = {"channel": conversation_id}
+ params: Params = {"channel": conversation_id}
response: SlackConversationsInfoResponse = await self._fetch(method, params)
if response["ok"] is False:
raise SlackApiError(self.workspace, method, response, params)
@@ -112,7 +112,7 @@ class SlackApi:
pages: int = -1,
):
method = "conversations.members"
- params = {"channel": conversation.id, "limit": limit}
+ params: Params = {"channel": conversation.id, "limit": limit}
response: SlackConversationsMembersResponse = await self._fetch_list(
method, "members", params, pages
)
@@ -128,7 +128,7 @@ class SlackApi:
pages: int = -1,
):
method = "users.conversations"
- params = {
+ params: Params = {
"types": types,
"exclude_archived": exclude_archived,
"limit": limit,
@@ -145,7 +145,7 @@ class SlackApi:
async def fetch_user_info(self, user_id: str):
method = "users.info"
- params = {"user": user_id}
+ params: Params = {"user": user_id}
response: SlackUserInfoResponse = await self._fetch(method, params)
if response["ok"] is False:
raise SlackApiError(self.workspace, method, response, params)
@@ -153,7 +153,7 @@ class SlackApi:
async def fetch_users_info(self, user_ids: Iterable[str]):
method = "users.info"
- params = {"users": ",".join(user_ids)}
+ params: Params = {"users": ",".join(user_ids)}
response: SlackUsersInfoResponse = await self._fetch(method, params)
if response["ok"] is False:
raise SlackApiError(self.workspace, method, response, params)
@@ -161,7 +161,7 @@ class SlackApi:
async def fetch_bot_info(self, bot_id: str):
method = "bots.info"
- params = {"bot": bot_id}
+ params: Params = {"bot": bot_id}
response: SlackBotInfoResponse = await self._fetch(method, params)
if response["ok"] is False:
raise SlackApiError(self.workspace, method, response, params)
@@ -169,7 +169,7 @@ class SlackApi:
async def fetch_bots_info(self, bot_ids: Iterable[str]):
method = "bots.info"
- params = {"bots": ",".join(bot_ids)}
+ params: Params = {"bots": ",".join(bot_ids)}
response: SlackBotsInfoResponse = await self._fetch(method, params)
if response["ok"] is False:
raise SlackApiError(self.workspace, method, response, params)
@@ -184,7 +184,7 @@ class SlackApi:
async def fetch_usergroups_info(self, usergroup_ids: Sequence[str]):
method = "usergroups/info"
- params = {"ids": usergroup_ids}
+ params: EdgeParams = {"ids": usergroup_ids}
response: SlackEdgeUsergroupsInfoResponse = await self._fetch_edgeapi(
method, params
)
@@ -194,7 +194,7 @@ class SlackApi:
async def fetch_users_search(self, query: str):
method = "users/search"
- params = {
+ params: EdgeParams = {
"include_profile_only_users": True,
"query": query,
"count": 25,
diff --git a/typings/slack_api/slack_conversations_info.pyi b/typings/slack_api/slack_conversations_info.pyi
index 3ad286e..ec3068f 100644
--- a/typings/slack_api/slack_conversations_info.pyi
+++ b/typings/slack_api/slack_conversations_info.pyi
@@ -1,10 +1,10 @@
from __future__ import annotations
-from typing import Generic, List
+from typing import Generic, List, TypeVar
from slack_api.slack_common import SlackErrorResponse
from slack_api.slack_conversations_history import SlackMessage
-from typing_extensions import Literal, TypedDict, TypeVar, final
+from typing_extensions import Literal, TypedDict, final
T = TypeVar("T")
diff --git a/typings/slack_api/slack_users_conversations.pyi b/typings/slack_api/slack_users_conversations.pyi
index 391bca0..cbeca8d 100644
--- a/typings/slack_api/slack_users_conversations.pyi
+++ b/typings/slack_api/slack_users_conversations.pyi
@@ -1,9 +1,9 @@
from __future__ import annotations
-from typing import Generic, List
+from typing import Generic, List, TypeVar
from slack_api.slack_common import SlackErrorResponse, SlackResponseMetadata
-from typing_extensions import Literal, TypedDict, TypeVar, final
+from typing_extensions import Literal, TypedDict, final
T = TypeVar("T")
diff --git a/typings/slack_api/slack_users_info.pyi b/typings/slack_api/slack_users_info.pyi
index d7ae367..a6a67d9 100644
--- a/typings/slack_api/slack_users_info.pyi
+++ b/typings/slack_api/slack_users_info.pyi
@@ -1,9 +1,9 @@
from __future__ import annotations
-from typing import Dict, Generic, List, Optional
+from typing import Dict, Generic, List, Optional, TypeVar
from slack_api.slack_common import SlackErrorResponse
-from typing_extensions import Literal, NotRequired, TypedDict, TypeVar, final
+from typing_extensions import Literal, NotRequired, TypedDict, final
T = TypeVar("T")