aboutsummaryrefslogtreecommitdiffstats
path: root/slack/commands.py
diff options
context:
space:
mode:
authorTrygve Aaberge <trygveaa@gmail.com>2023-01-14 04:55:37 +0100
committerTrygve Aaberge <trygveaa@gmail.com>2024-02-18 11:32:53 +0100
commit01583ccd6e4aa1755ac2ab4151a20537cfc0c8dc (patch)
treec522d89e908f8d7788c283ba804cb493296c265b /slack/commands.py
parent9009fa39dd5d6c4101e2f339182285d23abf0cf3 (diff)
downloadwee-slack-01583ccd6e4aa1755ac2ab4151a20537cfc0c8dc.tar.gz
Fix most mypy type errors
Diffstat (limited to 'slack/commands.py')
-rw-r--r--slack/commands.py19
1 files changed, 10 insertions, 9 deletions
diff --git a/slack/commands.py b/slack/commands.py
index 735ba35..1428175 100644
--- a/slack/commands.py
+++ b/slack/commands.py
@@ -233,13 +233,14 @@ def find_command(start_cmd: str, args: str) -> Optional[Tuple[Command, str]]:
cmd_args = args[cmd_args_startpos:]
if cmd in commands:
return commands[cmd], cmd_args
+ return None
def command_cb(data: str, buffer: str, args: str) -> int:
- cmd = find_command(data, args)
- if cmd:
- command = cmd[0]
- cmd_args = cmd[1]
+ found_cmd_with_args = find_command(data, args)
+ if found_cmd_with_args:
+ command = found_cmd_with_args[0]
+ cmd_args = found_cmd_with_args[1]
command.cb(buffer, cmd_args)
else:
print_error(
@@ -264,9 +265,9 @@ def completion_slack_workspace_commands_cb(
args = weechat.completion_get_string(completion, "args")
args_without_base_word = args.removesuffix(base_word)
- cmd = find_command(base_command, args_without_base_word)
- if cmd:
- command = cmd[0]
+ found_cmd_with_args = find_command(base_command, args_without_base_word)
+ if found_cmd_with_args:
+ command = found_cmd_with_args[0]
matching_cmds = [
cmd.removeprefix(command.cmd).lstrip()
for cmd in commands
@@ -274,9 +275,9 @@ def completion_slack_workspace_commands_cb(
]
if len(matching_cmds) > 1:
for match in matching_cmds:
- arg = match.split(" ")
+ cmd_arg = match.split(" ")
completion_list_add(
- completion, arg[0], 0, weechat.WEECHAT_LIST_POS_SORT
+ completion, cmd_arg[0], 0, weechat.WEECHAT_LIST_POS_SORT
)
else:
for arg in command.completion.split("|"):