Skip to content

Commit

Permalink
argument parsing: add types
Browse files Browse the repository at this point in the history
  • Loading branch information
grahamc committed Mar 22, 2020
1 parent e61207c commit b30372e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions nixops/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
# -*- coding: utf-8 -*-

from nixops import deployment
from argparse import ArgumentParser, SUPPRESS, REMAINDER
from argparse import ArgumentParser, _SubParsersAction, SUPPRESS, REMAINDER
import os
from nixops.script_defs import *

# Set up the parser.
parser = ArgumentParser(description="NixOS cloud deployment tool", prog="nixops")
parser.add_argument("--version", action="version", version="NixOps @version@")

subparsers = parser.add_subparsers(
subparsers: _SubParsersAction = parser.add_subparsers(
help="sub-command help", metavar="operation", required=True
)

Expand Down
10 changes: 6 additions & 4 deletions nixops/script_defs.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import nixops.statefile
import prettytable
from argparse import Namespace
from argparse import ArgumentParser, _SubParsersAction, Namespace
import os
import pwd
import re
Expand Down Expand Up @@ -974,7 +974,9 @@ def setup_logging(args):
nixops.util.TeeStdout()


def add_subparser(subparsers, name, help):
def add_subparser(
subparsers: _SubParsersAction, name: str, help: str
) -> ArgumentParser:
subparser = subparsers.add_parser(name, help=help)
subparser.add_argument(
"--state",
Expand Down Expand Up @@ -1062,7 +1064,7 @@ def add_subparser(subparsers, name, help):
return subparser


def add_common_modify_options(subparser):
def add_common_modify_options(subparser: ArgumentParser):
subparser.add_argument(
"nix_exprs",
nargs="*",
Expand All @@ -1079,7 +1081,7 @@ def add_common_modify_options(subparser):
)


def add_common_deployment_options(subparser):
def add_common_deployment_options(subparser: ArgumentParser):
subparser.add_argument(
"--include",
nargs="+",
Expand Down

0 comments on commit b30372e

Please sign in to comment.