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
|
|
@ -1,6 +1,9 @@
|
|||
from __future__ import annotations
|
||||
import abc
|
||||
import argparse
|
||||
from abc import ABC
|
||||
from argparse import ArgumentParser, _SubParsersAction
|
||||
from typing import List, Type, Union, TypeVar
|
||||
|
||||
from jwutils import log
|
||||
|
||||
|
|
@ -13,28 +16,28 @@ class Cmd(ABC): # export
|
|||
async def run(self, args):
|
||||
pass
|
||||
|
||||
def __init__(self, name, help):
|
||||
def __init__(self, name: str, help: str) -> None:
|
||||
self.name = name
|
||||
self.help = help
|
||||
self.parent = None
|
||||
self.children = []
|
||||
self.child_classes = []
|
||||
self.children: List[Cmd] = []
|
||||
self.child_classes: List[Type[Cmd]] = []
|
||||
|
||||
async def _run(self, args):
|
||||
pass
|
||||
|
||||
def add_parser(self, parsers):
|
||||
def add_parser(self, parsers) -> ArgumentParser:
|
||||
r = parsers.add_parser(self.name, help=self.help,
|
||||
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
|
||||
r.set_defaults(func=self.run)
|
||||
return r
|
||||
|
||||
def add_subcommands(self, cmd):
|
||||
def add_subcommands(self, cmd: Union[Type[Cmd], List[Type[Cmd]]]) -> None:
|
||||
if isinstance(cmd, list):
|
||||
for c in cmd:
|
||||
self.add_subcommands(c)
|
||||
return
|
||||
self.child_classes.append(cmd)
|
||||
|
||||
def add_arguments(self, parser):
|
||||
def add_arguments(self, parser: ArgumentParser) -> None:
|
||||
pass
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue