From fa69b9964ce939d9cdd2f303d99cdc1cf00b4dc4 Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Fri, 6 Oct 2023 10:52:31 +0200 Subject: [PATCH] ENH: remove GitPod config if `--no-gitpod` --- src/repoma/check_dev_files/__init__.py | 5 ++--- src/repoma/check_dev_files/gitpod.py | 8 +++++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/repoma/check_dev_files/__init__.py b/src/repoma/check_dev_files/__init__.py index d0d1313a..cefd0367 100644 --- a/src/repoma/check_dev_files/__init__.py +++ b/src/repoma/check_dev_files/__init__.py @@ -32,7 +32,7 @@ ) -def main(argv: Optional[Sequence[str]] = None) -> int: # noqa: PLR0915 +def main(argv: Optional[Sequence[str]] = None) -> int: parser = argparse.ArgumentParser(__doc__) parser.add_argument( "--allow-deprecated-workflows", @@ -200,8 +200,7 @@ def main(argv: Optional[Sequence[str]] = None) -> int: # noqa: PLR0915 executor(setup_cfg.main, args.ignore_author) executor(remove_deprecated_tools, args.keep_issue_templates) executor(vscode.main, has_notebooks) - if not args.no_gitpod: - executor(gitpod.main) + executor(gitpod.main, args.no_gitpod) executor(precommit.main) return executor.finalize(exception=False) diff --git a/src/repoma/check_dev_files/gitpod.py b/src/repoma/check_dev_files/gitpod.py index a50006c5..0681567b 100644 --- a/src/repoma/check_dev_files/gitpod.py +++ b/src/repoma/check_dev_files/gitpod.py @@ -14,7 +14,13 @@ __CONSTRAINTS_FILE = ".constraints/py3.8.txt" -def main() -> None: +def main(no_gitpod: bool) -> None: + if no_gitpod: + if CONFIG_PATH.gitpod.exists(): + os.remove(CONFIG_PATH.gitpod) + msg = f"Removed {CONFIG_PATH.gitpod} as requested by --no-gitpod" + raise PrecommitError(msg) + return pin_dependencies = os.path.exists(__CONSTRAINTS_FILE) error_message = "" expected_config = _generate_gitpod_config(pin_dependencies)