mirror of
ssh://git.janware.com/srv/git/janware/proj/jw-python
synced 2026-01-15 09:53:32 +01:00
Add type annotations from monkeytype + jw-devops/test
Add type annotations as generated by monkeytype and jw-devops/test, plus some hand editing to satisfy both monkeytype and mypy. Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
952bf4a4e1
commit
77d43aebad
7 changed files with 51 additions and 42 deletions
|
|
@ -6,6 +6,8 @@ import inspect
|
|||
import re
|
||||
import pickle
|
||||
import asyncio
|
||||
from argparse import ArgumentParser
|
||||
from typing import Optional
|
||||
|
||||
import jwutils
|
||||
from jwutils.log import *
|
||||
|
|
@ -29,7 +31,7 @@ class Cmds: # export
|
|||
for sub_cmd in cmd.children:
|
||||
self.__add_cmd_to_parser(sub_cmd, subparsers)
|
||||
|
||||
def __init__(self, description = '', filter = '^Cmd.*', modules=None, eloop=None):
|
||||
def __init__(self, description: str = '', filter: str = '^Cmd.*', modules: None=None, eloop: None=None) -> None:
|
||||
self.__description = description
|
||||
self.__filter = filter
|
||||
self.__modules = modules
|
||||
|
|
@ -40,7 +42,7 @@ class Cmds: # export
|
|||
self.eloop = asyncio.get_event_loop()
|
||||
self.__own_eloop = True
|
||||
|
||||
log_level = NOTICE
|
||||
log_level = "notice"
|
||||
log_flags = 'stderr,position,prio,color'
|
||||
# poor man's parsing in the absence of a complete command-line definition
|
||||
for i in range(1, len(sys.argv)):
|
||||
|
|
@ -65,7 +67,7 @@ class Cmds: # export
|
|||
self.__modules = [ '__main__' ]
|
||||
subcmds = set()
|
||||
slog(DEBUG, '-- searching for commands')
|
||||
for m in self.__modules:
|
||||
for m in self.__modules: # type: ignore
|
||||
if m != '__main__':
|
||||
importlib.import_module(m)
|
||||
for name, c in inspect.getmembers(sys.modules[m], inspect.isclass):
|
||||
|
|
@ -99,12 +101,12 @@ class Cmds: # export
|
|||
self.eloop = None
|
||||
self.__own_eloop = False
|
||||
|
||||
def parser(self):
|
||||
def parser(self) -> ArgumentParser:
|
||||
return self.__parser
|
||||
|
||||
def run(self):
|
||||
def run(self) -> None:
|
||||
#return self.__run()
|
||||
return self.eloop.run_until_complete(self.__run())
|
||||
return self.eloop.run_until_complete(self.__run()) # type: ignore
|
||||
|
||||
def run_sub_commands(description = '', filter = '^Cmd.*', modules=None): # export
|
||||
cmds = Cmds(description, filter, modules)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue