From 60847f59f5f97c440e7addd72f2af3e0d6e86f6e Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Wed, 16 Oct 2024 16:36:15 +0200 Subject: [PATCH] FIX: do not write `.binder/apt.txt` if no `apt` packages --- src/compwa_policy/check_dev_files/binder.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/compwa_policy/check_dev_files/binder.py b/src/compwa_policy/check_dev_files/binder.py index 82ad8c08..83b881a6 100644 --- a/src/compwa_policy/check_dev_files/binder.py +++ b/src/compwa_policy/check_dev_files/binder.py @@ -54,10 +54,12 @@ def _check_optional_dependencies() -> None: def _update_apt_txt(apt_packages: list[str]) -> None: apt_txt = CONFIG_PATH.binder / "apt.txt" - if not apt_packages and apt_txt.exists(): - apt_txt.unlink() - msg = f"Removed {apt_txt}, because --doc-apt-packages does not specify any packages." - raise PrecommitError(msg) + if not apt_packages: + if apt_txt.exists(): + apt_txt.unlink() + msg = f"Removed {apt_txt}, because --doc-apt-packages does not specify any packages." + raise PrecommitError(msg) + return apt_packages = sorted(set(apt_packages)) __update_file( expected_content="\n".join(apt_packages) + "\n",