From 602a06e5cba818cb927c45566a610eb3e0d6eadc Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Fri, 18 Dec 2020 11:14:07 -0500 Subject: [PATCH] Extract Parameters type in scripts.types_. --- src/allmydata/scripts/cli.py | 5 ++--- src/allmydata/scripts/common.py | 7 ++++--- src/allmydata/scripts/types_.py | 4 +++- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/allmydata/scripts/cli.py b/src/allmydata/scripts/cli.py index 2bb91472f..e4cd8aa22 100644 --- a/src/allmydata/scripts/cli.py +++ b/src/allmydata/scripts/cli.py @@ -3,8 +3,7 @@ from __future__ import print_function import os.path, re, fnmatch try: - from typing import List, Sequence, Any - from allmydata.scripts.types_ import SubCommands + from allmydata.scripts.types_ import SubCommands, Parameters except ImportError: pass @@ -26,7 +25,7 @@ class FileStoreOptions(BaseOptions): "This overrides the URL found in the --node-directory ."], ["dir-cap", None, None, "Specify which dirnode URI should be used as the 'tahoe' alias."] - ] # type: List[Sequence[Any]] + ] # type: Parameters def postOptions(self): self["quiet"] = self.parent["quiet"] diff --git a/src/allmydata/scripts/common.py b/src/allmydata/scripts/common.py index b501c7e6a..42c26bb90 100644 --- a/src/allmydata/scripts/common.py +++ b/src/allmydata/scripts/common.py @@ -5,7 +5,8 @@ import codecs from os.path import join try: - from typing import Optional, Sequence, List, Any + from typing import Optional + from .types_ import Parameters except ImportError: pass @@ -69,7 +70,7 @@ class BasedirOptions(BaseOptions): optParameters = [ ["basedir", "C", None, "Specify which Tahoe base directory should be used. [default: %s]" % quote_local_unicode_path(_default_nodedir)], - ] # type: List[Sequence[Any]] + ] # type: Parameters def parseArgs(self, basedir=None): # This finds the node-directory option correctly even if we are in a subcommand. @@ -106,7 +107,7 @@ class NoDefaultBasedirOptions(BasedirOptions): optParameters = [ ["basedir", "C", None, "Specify which Tahoe base directory should be used."], - ] # type: List[Sequence[Any]] + ] # type: Parameters # This is overridden in order to ensure we get a "Wrong number of arguments." # error when more than one argument is given. diff --git a/src/allmydata/scripts/types_.py b/src/allmydata/scripts/types_.py index 58f88722b..3937cb803 100644 --- a/src/allmydata/scripts/types_.py +++ b/src/allmydata/scripts/types_.py @@ -1,4 +1,4 @@ -from typing import List, Tuple, Type +from typing import List, Tuple, Type, Sequence, Any from allmydata.scripts.common import BaseOptions @@ -8,3 +8,5 @@ from allmydata.scripts.common import BaseOptions SubCommand = Tuple[str, None, Type[BaseOptions], str] SubCommands = List[SubCommand] + +Parameters = List[Sequence[Any]]