Skip to content

Commit

Permalink
Add type annotation to aiven cli
Browse files Browse the repository at this point in the history
  • Loading branch information
Don Dang committed Apr 29, 2022
1 parent 371f5ea commit b60195e
Show file tree
Hide file tree
Showing 12 changed files with 434 additions and 406 deletions.
3 changes: 2 additions & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ disable=
ungrouped-imports,
use-sequence-for-iteration,
wrong-import-order,
wrong-import-position
wrong-import-position,
no-member

[FORMAT]
max-line-length=125
Expand Down
7 changes: 4 additions & 3 deletions aiven/client/argx.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from .pretty import TableLayout
from aiven.client import envdefault, pretty
from argparse import Action
from argparse import Action, Namespace
from os import PathLike
from typing import (
Any,
Expand Down Expand Up @@ -144,9 +144,10 @@ def save(self) -> None:


class CommandLineTool: # pylint: disable=old-style-class
config: Config

def __init__(self, name: str, parser: Optional[argparse.ArgumentParser] = None):
self.log = logging.getLogger(name)
self.config: Optional[Config] = None
self._cats: Dict[Tuple[str, ...], argparse._SubParsersAction] = {}
self._extensions: List[CommandLineTool] = []
self.parser = parser or argparse.ArgumentParser(prog=name, formatter_class=CustomFormatter)
Expand All @@ -157,7 +158,7 @@ def __init__(self, name: str, parser: Optional[argparse.ArgumentParser] = None):
)
self.parser.add_argument("--version", action="version", version="aiven-client {}".format(__version__))
self.subparsers = self.parser.add_subparsers(title="command categories", dest="command", help="", metavar="")
self.args: Optional[argparse.Namespace] = None
self.args: Namespace = Namespace()

def add_cmd(self, func: Callable) -> None:
"""Add a parser for a single command method call"""
Expand Down
Loading

0 comments on commit b60195e

Please sign in to comment.