Extract Parameters type in scripts.types_.

This commit is contained in:
Jason R. Coombs 2020-12-18 11:14:07 -05:00
parent 189608e113
commit 602a06e5cb
3 changed files with 9 additions and 7 deletions

View File

@ -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"]

View File

@ -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.

View File

@ -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]]