Skip to content

Commit c9e6dda

Browse files
chore: add type-hints to imapclient/interact.py
1 parent 97caa94 commit c9e6dda

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed

imapclient/interact.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@
77
import argparse
88
from getpass import getpass
99

10+
from . import imapclient
1011
from .config import create_client_from_config, get_config_defaults, parse_config_file
1112

1213

13-
def command_line():
14+
def command_line() -> argparse.Namespace:
1415
parser = argparse.ArgumentParser()
1516
parser.add_argument(
1617
"-H", "--host", dest="host", action="store", help="IMAP host connect to"
@@ -95,36 +96,38 @@ def command_line():
9596
return args
9697

9798

98-
def main():
99+
def main() -> int:
99100
args = command_line()
100101
print("Connecting...")
101102
client = create_client_from_config(args)
102103
print("Connected.")
103104
banner = '\nIMAPClient instance is "c"'
104105

105-
def ptpython(c):
106-
from ptpython.repl import embed
106+
def ptpython(c: imapclient.IMAPClient) -> None:
107+
from ptpython.repl import embed # type: ignore[import]
107108

108109
embed(globals(), locals())
109110

110-
def ipython_400(c):
111-
from IPython.terminal.embed import InteractiveShellEmbed
111+
def ipython_400(c: imapclient.IMAPClient) -> None:
112+
from IPython.terminal.embed import InteractiveShellEmbed # type: ignore[import]
112113

113114
ipshell = InteractiveShellEmbed(banner1=banner)
114115
ipshell("")
115116

116-
def ipython_011(c):
117-
from IPython.frontend.terminal.embed import InteractiveShellEmbed
117+
def ipython_011(c: imapclient.IMAPClient) -> None:
118+
from IPython.frontend.terminal.embed import ( # type: ignore[import]
119+
InteractiveShellEmbed,
120+
)
118121

119122
ipshell = InteractiveShellEmbed(banner1=banner)
120123
ipshell("")
121124

122-
def ipython_010(c):
123-
from IPython.Shell import IPShellEmbed
125+
def ipython_010(c: imapclient.IMAPClient) -> None:
126+
from IPython.Shell import IPShellEmbed # type: ignore[import]
124127

125128
IPShellEmbed("", banner=banner)()
126129

127-
def builtin(c):
130+
def builtin(c: imapclient.IMAPClient) -> None:
128131
import code
129132

130133
code.interact(banner, local={"c": c})
@@ -143,6 +146,7 @@ def builtin(c):
143146
pass
144147
else:
145148
break
149+
return 0
146150

147151

148152
if __name__ == "__main__":

pyproject.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,6 @@ warn_unused_ignores = true
4848
[[tool.mypy.overrides]]
4949
module = [
5050
"imapclient.imapclient",
51-
"imapclient.interact",
52-
"interact",
5351
"livetest",
5452
]
5553
ignore_errors = true

0 commit comments

Comments
 (0)