From db1c4a767a0487681341e5a6ce7d000f5b330e81 Mon Sep 17 00:00:00 2001 From: "Stein M. Nornes" Date: Thu, 21 Aug 2025 21:04:18 +0200 Subject: [PATCH 1/2] Add Ruff validation (but ignore errors for the time being) --- .github/workflows/validate.yaml | 19 +++++++++++++++++++ scripts/lint | 12 ++++++++++-- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/.github/workflows/validate.yaml b/.github/workflows/validate.yaml index 188829e..9d45090 100644 --- a/.github/workflows/validate.yaml +++ b/.github/workflows/validate.yaml @@ -26,3 +26,22 @@ jobs: uses: hacs/action@main with: category: integration + + lint-ruff: + name: Ruff validation + runs-on: ubuntu-latest + steps: + - name: Checkout the repository + uses: actions/checkout@v4 + + - name: Run ruff format + uses: astral-sh/ruff-action@v3 + with: + args: format --diff + src: "." + + - name: Run ruff check + uses: astral-sh/ruff-action@v3 + with: + args: check --exit-zero # succeed despite errors until https://github.com/custom-components/zaptec/issues/258 is done + src: "." diff --git a/scripts/lint b/scripts/lint index 5d68d15..c70206c 100755 --- a/scripts/lint +++ b/scripts/lint @@ -4,5 +4,13 @@ set -e cd "$(dirname "$0")/.." -ruff format . -ruff check . --fix +if [ "$1" = "ci" ]; then + # Don't try to fix errors, just fail + ruff format . --diff + ruff check . --exit-zero # succeed despite errors until https://github.com/custom-components/zaptec/issues/258 is done + # ruff check . +else + # Auto-fix as much as possible + ruff format . + ruff check . --fix +fi From e8b1555067ddff8b1556bd9354afe7ceddad28c1 Mon Sep 17 00:00:00 2001 From: "Stein M. Nornes" Date: Thu, 21 Aug 2025 21:08:54 +0200 Subject: [PATCH 2/2] Fix (semi-)intentional formatting error --- custom_components/zaptec/services.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/custom_components/zaptec/services.py b/custom_components/zaptec/services.py index f65762c..7114e00 100644 --- a/custom_components/zaptec/services.py +++ b/custom_components/zaptec/services.py @@ -283,11 +283,17 @@ async def service_handle_limit_current(service_call: ServiceCall) -> None: # only add the relevant arguments if they are not None if (available_current := service_call.data.get("available_current")) is not None: limit_args["availableCurrent"] = available_current - if (available_current_phase1 := service_call.data.get("available_current_phase1")) is not None: + if ( + available_current_phase1 := service_call.data.get("available_current_phase1") + ) is not None: limit_args["availableCurrentPhase1"] = available_current_phase1 - if (available_current_phase2 := service_call.data.get("available_current_phase2")) is not None: + if ( + available_current_phase2 := service_call.data.get("available_current_phase2") + ) is not None: limit_args["availableCurrentPhase2"] = available_current_phase2 - if (available_current_phase3 := service_call.data.get("available_current_phase3")) is not None: + if ( + available_current_phase3 := service_call.data.get("available_current_phase3") + ) is not None: limit_args["availableCurrentPhase3"] = available_current_phase3 for coordinator, obj in iter_objects(service_call, mustbe=Installation): _LOGGER.debug(" >> to %s", obj.id)