lint: tidy up code in cli module

This commit is contained in:
Iain Learmonth 2022-06-17 13:21:35 +01:00
parent 5f7733d064
commit 98895e47de
6 changed files with 61 additions and 58 deletions

View file

@ -1,23 +1,18 @@
import argparse
import json
import logging
import sys
from typing import Callable, TYPE_CHECKING, Any
from typing import Callable, Any
from app import app
from app.cli import _SubparserType, BaseCliHandler
from app.lists import lists
if TYPE_CHECKING:
_SubparserType = argparse._SubParsersAction[argparse.ArgumentParser]
else:
_SubparserType = Any
def dump(list_f: Callable[[], Any]) -> None:
json.dump(list_f(), sys.stdout, indent=2)
class ListCliHandler:
class ListCliHandler(BaseCliHandler):
@classmethod
def add_subparser_to(cls, subparsers: _SubparserType) -> None:
parser = subparsers.add_parser("list", help="list operations")
@ -25,9 +20,6 @@ class ListCliHandler:
help="dump a list in JSON format")
parser.set_defaults(cls=cls)
def __init__(self, args: argparse.Namespace) -> None:
self.args = args
def run(self) -> None:
with app.app_context():
if self.args.dump: