From deb099d6d838a82b616edecfc19c75452a6a9aea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=80=8Credacted=E3=80=8D?= <87243354+information-redacted@users.noreply.github.com> Date: Wed, 20 Aug 2025 02:43:34 +0300 Subject: [PATCH 1/2] fix(operations/crontab): only provide command if cron_name is not provided --- src/pyinfra/operations/crontab.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pyinfra/operations/crontab.py b/src/pyinfra/operations/crontab.py index b7849af50..0f979f5d4 100644 --- a/src/pyinfra/operations/crontab.py +++ b/src/pyinfra/operations/crontab.py @@ -84,7 +84,7 @@ def comma_sep(value): ctb = ctb0 name_comment = "# pyinfra-name={0}".format(cron_name) - existing_crontab = ctb.get_command(command=command, name=cron_name) + existing_crontab = ctb.get_command(command=[command if cron_name is None else None], name=cron_name) existing_crontab_command = existing_crontab["command"] if existing_crontab else command existing_crontab_match = existing_crontab["command"] if existing_crontab else command From 47c3c764162de26e690902adf2f96e032d302b57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=80=8Credacted=E3=80=8D?= <87243354+information-redacted@users.noreply.github.com> Date: Wed, 20 Aug 2025 03:00:41 +0300 Subject: [PATCH 2/2] fix(operations/crontab): lint + remove list comprehension from inline if --- src/pyinfra/operations/crontab.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/pyinfra/operations/crontab.py b/src/pyinfra/operations/crontab.py index 0f979f5d4..e8ba66f8e 100644 --- a/src/pyinfra/operations/crontab.py +++ b/src/pyinfra/operations/crontab.py @@ -84,7 +84,9 @@ def comma_sep(value): ctb = ctb0 name_comment = "# pyinfra-name={0}".format(cron_name) - existing_crontab = ctb.get_command(command=[command if cron_name is None else None], name=cron_name) + existing_crontab = ctb.get_command( + command=command if cron_name is None else None, name=cron_name + ) existing_crontab_command = existing_crontab["command"] if existing_crontab else command existing_crontab_match = existing_crontab["command"] if existing_crontab else command