Skip to content

Commit

Permalink
Update prepare command
Browse files Browse the repository at this point in the history
  • Loading branch information
Qalthos committed Oct 29, 2024
1 parent a34bd5a commit bb58f34
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 23 deletions.
11 changes: 0 additions & 11 deletions .config/pydoclint-baseline.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,6 @@ src/molecule/command/init/scenario.py
DOC107: Function `scenario`: The option `--arg-type-hints-in-signature` is `True` but not all args in the signature have type hints
DOC103: Function `scenario`: Docstring arguments are different from function arguments. (Or could be other formatting issues: https://jsh9.github.io/pydoclint/violation_codes.html#notes-on-doc103 ). Arguments in the function signature but not in the docstring: [ctx: , dependency_name: , driver_name: , provisioner_name: , scenario_name: ].
--------------------
src/molecule/command/prepare.py
DOC101: Method `Prepare.execute`: Docstring contains fewer arguments than in function signature.
DOC106: Method `Prepare.execute`: The option `--arg-type-hints-in-signature` is `True` but there are no argument type hints in the signature
DOC107: Method `Prepare.execute`: The option `--arg-type-hints-in-signature` is `True` but not all args in the signature have type hints
DOC103: Method `Prepare.execute`: Docstring arguments are different from function arguments. (Or could be other formatting issues: https://jsh9.github.io/pydoclint/violation_codes.html#notes-on-doc103 ). Arguments in the function signature but not in the docstring: [action_args: ].
DOC201: Method `Prepare.execute` does not have a return section in docstring
DOC101: Function `prepare`: Docstring contains fewer arguments than in function signature.
DOC106: Function `prepare`: The option `--arg-type-hints-in-signature` is `True` but there are no argument type hints in the signature
DOC107: Function `prepare`: The option `--arg-type-hints-in-signature` is `True` but not all args in the signature have type hints
DOC103: Function `prepare`: Docstring arguments are different from function arguments. (Or could be other formatting issues: https://jsh9.github.io/pydoclint/violation_codes.html#notes-on-doc103 ). Arguments in the function signature but not in the docstring: [ctx: , driver_name: , force: , scenario_name: ].
--------------------
src/molecule/command/reset.py
DOC101: Function `reset`: Docstring contains fewer arguments than in function signature.
DOC106: Function `reset`: The option `--arg-type-hints-in-signature` is `True` but there are no argument type hints in the signature
Expand Down
41 changes: 29 additions & 12 deletions src/molecule/command/prepare.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@


if TYPE_CHECKING:
from molecule.types import CommandArgs
from molecule.types import CommandArgs, MoleculeArgs


LOG = logging.getLogger(__name__)
Expand Down Expand Up @@ -91,20 +91,25 @@ class Prepare(base.Base):
molecule.yml.
"""

def execute(self, action_args=None): # type: ignore[no-untyped-def] # noqa: ANN001, ANN201, ARG002
"""Execute the actions necessary to prepare the instances and returns None."""
def execute(self, action_args: list[str] | None = None) -> None: # noqa: ARG002
"""Execute the actions necessary to prepare the instances.
Args:
action_args: Arguments for this command. Unused.
"""
if self._config.state.prepared and not self._config.command_args.get("force"):
msg = "Skipping, instances already prepared."
LOG.warning(msg)
return

if not self._config.provisioner.playbooks.prepare: # type: ignore[union-attr]
msg = "Skipping, prepare playbook not configured."
LOG.warning(msg)
return
if self._config.provisioner:
if not self._config.provisioner.playbooks.prepare:
msg = "Skipping, prepare playbook not configured."
LOG.warning(msg)
return

self._config.provisioner.prepare() # type: ignore[union-attr]
self._config.state.change_state("prepared", True) # noqa: FBT003
self._config.provisioner.prepare() # type: ignore[no-untyped-call]
self._config.state.change_state("prepared", value=True)


@base.click_command_ex()
Expand All @@ -127,9 +132,21 @@ def execute(self, action_args=None): # type: ignore[no-untyped-def] # noqa: AN
default=False,
help="Enable or disable force mode. Default is disabled.",
)
def prepare(ctx, scenario_name, driver_name, force): # type: ignore[no-untyped-def] # pragma: no cover # noqa: ANN001, ANN201
"""Use the provisioner to prepare the instances into a particular starting state."""
args = ctx.obj.get("args")
def prepare(
ctx: click.Context,
scenario_name: str,
driver_name: str,
force: bool, # noqa: FBT001
) -> None: # pragma: no cover
"""Use the provisioner to prepare the instances into a particular starting state.
Args:
ctx: Click context object holding commandline arguments.
scenario_name: Name of the scenario to target.
driver_name: Name of the Molecule driver to use.
force: Whether to use force mode.
"""
args: MoleculeArgs = ctx.obj.get("args")
subcommand = base._get_subcommand(__name__) # noqa: SLF001
command_args: CommandArgs = {
"subcommand": subcommand,
Expand Down

0 comments on commit bb58f34

Please sign in to comment.