Skip to content

Commit cca1b7d

Browse files
neiljptimabbott
authored andcommitted
mypy: Add types to terminal.py.
1 parent 4982adc commit cca1b7d

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

tools/run-mypy

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ exclude = [
2323
"zulip_bots/zulip_bots/bots",
2424
"zulip_bots/zulip_bots/bots_unmaintained",
2525
# Excluded out of laziness:
26-
"zulip_bots/zulip_bots/terminal.py",
2726
"zulip_bots/zulip_bots/simple_lib.py",
2827
"zulip_bots/zulip_bots/tests/test_lib.py",
2928
# Excluded because this is a self-contained script

zulip_bots/zulip_bots/terminal.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
current_dir = os.path.dirname(os.path.abspath(__file__))
1010

1111

12-
def parse_args():
12+
def parse_args() -> argparse.Namespace:
1313
description = """
1414
This tool allows you to test a bot using the terminal (and no Zulip server).
1515
@@ -32,15 +32,21 @@ def parse_args():
3232
return args
3333

3434

35-
def main():
35+
def main() -> None:
3636
args = parse_args()
3737

38-
bot_path, bot_name = resolve_bot_path(args.bot)
38+
# NOTE: Use of only this implies bots from eg. registry cannot be explored in this way
39+
result = resolve_bot_path(args.bot)
40+
if result is None:
41+
print(f"Cannot find find and import bot '{args.bot}'")
42+
sys.exit(1)
43+
44+
bot_path, bot_name = result
3945
bot_dir = os.path.dirname(bot_path)
4046
sys.path.insert(0, bot_dir)
4147

4248
try:
43-
lib_module = import_module_from_source(bot_path, bot_name)
49+
lib_module = import_module_from_source(bot_path.as_posix(), bot_name)
4450
if lib_module is None:
4551
raise OSError
4652
except OSError:

0 commit comments

Comments
 (0)