← Back to team overview

launchpad-reviewers team mailing list archive

Re: [Merge] ~lgp171188/lpcraft:add-clean-command-clean-flag into lpcraft:main

 

Before I continue with the review, could you please run the linters?

This is done automatically via `tox` or `tox -e lint`.

If you do not want to run the linters manually, you can also do a `pre-commit install` once, and then when you try a `git commit` pre-commit runs automatically.

Thank you!

Diff comments:

> diff --git a/lpcraft/commands/clean.py b/lpcraft/commands/clean.py
> new file mode 100644
> index 0000000..d92dd32
> --- /dev/null
> +++ b/lpcraft/commands/clean.py
> @@ -0,0 +1,32 @@
> +# Copyright 2022 Canonical Ltd.  This software is licensed under the
> +# GNU General Public License version 3 (see the file LICENSE).
> +
> +from argparse import Namespace
> +from pathlib import Path
> +
> +from craft_cli import emit
> +
> +from lpcraft.config import Config
> +from lpcraft.providers import get_provider
> +
> +
> +def clean(args: Namespace) -> int:
> +    """
> +    Clean the managed environments for a project.
> +    """
> +    # Verify that the there is an lpcraft configuration file
> +    # before trying to clean a project.
> +    config_path = getattr(args, "config", Path(".launchpad.yaml"))
> +    _ = Config.load(config_path)

The usage of `_` for an unused variable is only common in e.g. a for loop, e.g.

for _ in range(4):
    do_something()

> +
> +    cwd = Path.cwd()
> +    emit.progress(f"Cleaning project {cwd.name!r}.")
> +
> +    provider = get_provider()
> +    provider.ensure_provider_is_available()
> +
> +    provider.clean_project_environments(
> +        project_name=cwd.name, project_path=cwd
> +    )
> +    emit.message(f"Cleaned project {cwd.name!r}.")
> +    return 0


-- 
https://code.launchpad.net/~lgp171188/lpcraft/+git/lpcraft/+merge/416656
Your team Launchpad code reviewers is requested to review the proposed merge of ~lgp171188/lpcraft:add-clean-command-clean-flag into lpcraft:main.



References