27
27
import sys
28
28
from pathlib import Path
29
29
30
+ from typing import Tuple
31
+
30
32
import discord
31
33
import pkg_resources
32
34
import aiohttp
33
35
import platform
34
36
35
- def show_version ():
37
+ def show_version () -> None :
36
38
entries = []
37
39
38
40
entries .append ('- Python v{0.major}.{0.minor}.{0.micro}-{0.releaselevel}' .format (sys .version_info ))
@@ -48,7 +50,7 @@ def show_version():
48
50
entries .append ('- system info: {0.system} {0.release} {0.version}' .format (uname ))
49
51
print ('\n ' .join (entries ))
50
52
51
- def core (parser , args ):
53
+ def core (parser , args ) -> None :
52
54
if args .version :
53
55
show_version ()
54
56
@@ -173,7 +175,7 @@ async def cog_after_invoke(self, ctx):
173
175
174
176
_translation_table = str .maketrans (_base_table )
175
177
176
- def to_path (parser , name , * , replace_spaces = False ):
178
+ def to_path (parser , name , * , replace_spaces = False ) -> Path :
177
179
if isinstance (name , Path ):
178
180
return name
179
181
@@ -188,7 +190,7 @@ def to_path(parser, name, *, replace_spaces=False):
188
190
name = name .replace (' ' , '-' )
189
191
return Path (name )
190
192
191
- def newbot (parser , args ):
193
+ def newbot (parser , args ) -> None :
192
194
new_directory = to_path (parser , args .directory ) / to_path (parser , args .name )
193
195
194
196
# as a note exist_ok for Path is a 3.5+ only feature
@@ -229,7 +231,7 @@ def newbot(parser, args):
229
231
230
232
print ('successfully made bot at' , new_directory )
231
233
232
- def newcog (parser , args ):
234
+ def newcog (parser , args ) -> None :
233
235
cog_dir = to_path (parser , args .directory )
234
236
try :
235
237
cog_dir .mkdir (exist_ok = True )
@@ -262,7 +264,7 @@ def newcog(parser, args):
262
264
else :
263
265
print ('successfully made cog at' , directory )
264
266
265
- def add_newbot_args (subparser ) :
267
+ def add_newbot_args (subparser : argparse . _SubParsersAction ) -> None :
266
268
parser = subparser .add_parser ('newbot' , help = 'creates a command bot project quickly' )
267
269
parser .set_defaults (func = newbot )
268
270
@@ -272,7 +274,7 @@ def add_newbot_args(subparser):
272
274
parser .add_argument ('--sharded' , help = 'whether to use AutoShardedBot' , action = 'store_true' )
273
275
parser .add_argument ('--no-git' , help = 'do not create a .gitignore file' , action = 'store_true' , dest = 'no_git' )
274
276
275
- def add_newcog_args (subparser ) :
277
+ def add_newcog_args (subparser : argparse . _SubParsersAction ) -> None :
276
278
parser = subparser .add_parser ('newcog' , help = 'creates a new cog template quickly' )
277
279
parser .set_defaults (func = newcog )
278
280
@@ -283,7 +285,7 @@ def add_newcog_args(subparser):
283
285
parser .add_argument ('--hide-commands' , help = 'whether to hide all commands in the cog' , action = 'store_true' )
284
286
parser .add_argument ('--full' , help = 'add all special methods as well' , action = 'store_true' )
285
287
286
- def parse_args ():
288
+ def parse_args () -> Tuple [ argparse . ArgumentParser , argparse . Namespace ] :
287
289
parser = argparse .ArgumentParser (prog = 'discord' , description = 'Tools for helping with discord.py' )
288
290
parser .add_argument ('-v' , '--version' , action = 'store_true' , help = 'shows the library version' )
289
291
parser .set_defaults (func = core )
@@ -293,7 +295,7 @@ def parse_args():
293
295
add_newcog_args (subparser )
294
296
return parser , parser .parse_args ()
295
297
296
- def main ():
298
+ def main () -> None :
297
299
parser , args = parse_args ()
298
300
args .func (parser , args )
299
301
0 commit comments