Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions looper/cli_divvy.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@


def build_argparser():
"""
Builds argument parser.
"""Builds argument parser.

:return argparse.ArgumentParser
Returns:
argparse.ArgumentParser: The argument parser.
"""

banner = (
Expand Down
21 changes: 13 additions & 8 deletions looper/cli_pydantic.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,18 +380,23 @@ def main_cli() -> None:


def _proc_resources_spec(args):
"""
Process CLI-sources compute setting specification. There are two sources
of compute settings in the CLI alone:
"""Process CLI-sources compute setting specification.

There are two sources of compute settings in the CLI alone:
* YAML file (--settings argument)
* itemized compute settings (--compute argument)

The itemized compute specification is given priority
The itemized compute specification is given priority.

Args:
args (argparse.Namespace): Arguments namespace.

Returns:
Mapping[str, str]: Binding between resource setting name and value.

:param argparse.Namespace: arguments namespace
:return Mapping[str, str]: binding between resource setting name and value
:raise ValueError: if interpretation of the given specification as encoding
of key-value pairs fails
Raises:
ValueError: If interpretation of the given specification as encoding
of key-value pairs fails.
"""
spec = getattr(args, "compute", None)
settings = args.settings
Expand Down
18 changes: 9 additions & 9 deletions looper/command_models/arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@


class Argument(pydantic.fields.FieldInfo):
"""
CLI argument / flag definition
"""CLI argument / flag definition.

This class is designed to define CLI arguments or flags. It leverages
Pydantic for data validation and serves as a source of truth for multiple
Expand All @@ -24,13 +23,14 @@ class Argument(pydantic.fields.FieldInfo):
so we instead subclass `FieldInfo` directly and validate it in the
constructor.

:param str name: argument name, e.g. "ignore-args"
:param Any default: a tuple of the form (type, default_value). If the
default value is `...` (Ellipsis), then the argument is required.
:param str description: argument description, which will appear as the
help text for this argument
:param dict kwargs: additional keyword arguments supported by
`FieldInfo`. These are passed along as they are.
Args:
name (str): Argument name, e.g. "ignore-args".
default (Any): A tuple of the form (type, default_value). If the
default value is `...` (Ellipsis), then the argument is required.
description (str): Argument description, which will appear as the
help text for this argument.
kwargs (dict): Additional keyword arguments supported by
`FieldInfo`. These are passed along as they are.
"""

def __init__(
Expand Down
28 changes: 17 additions & 11 deletions looper/command_models/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@

@dataclass
class Command:
"""
Representation of a command
"""Representation of a command.

:param str name: command name
:param str description: command description
:param list[Argument] arguments: list of arguments supported by this command
Args:
name (str): Command name.
description (str): Command description.
arguments (list[Argument]): List of arguments supported by this command.
"""

name: str
Expand Down Expand Up @@ -242,13 +242,19 @@ def create_model(self) -> Type[pydantic.BaseModel]:
def add_short_arguments(
parser: ArgumentParser, argument_enums: Type[ArgumentEnum]
) -> ArgumentParser:
"""
This function takes a parser object created under pydantic argparse and adds the short arguments AFTER the initial creation.
This is a workaround as pydantic-argparse does not currently support this during initial parser creation.
"""Add short arguments to parser after initial creation.

This function takes a parser object created under pydantic argparse and adds
the short arguments AFTER the initial creation. This is a workaround as
pydantic-argparse does not currently support this during initial parser creation.

Args:
parser (ArgumentParser): Parser before adding short arguments.
argument_enums (Type[ArgumentEnum]): Enumeration of arguments that contain
names and aliases.

:param ArgumentParser parser: parser before adding short arguments
:param Type[ArgumentEnum] argument_enums: enumeration of arguments that contain names and aliases
:return ArgumentParser parser: parser after short arguments have been added
Returns:
ArgumentParser: Parser after short arguments have been added.
"""

for cmd in parser._subcommands.choices.keys():
Expand Down
Loading