From 81e9b979994d541730f90e605db6d0da49776361 Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Mon, 12 Jan 2026 17:18:43 +0100 Subject: [PATCH 1/4] Chores --- .github/workflows/verify.yml | 42 +++++++++++++++-------------------- .markdownlint.yaml | 2 -- .pre-commit-config.yaml | 15 ++++--------- .pymarkdown | 1 + CHANGELOG.md | 4 ++++ biome.json | 5 +++++ plugwise/legacy/smile.py | 2 +- plugwise/smile.py | 2 +- requirements_commit.txt | 2 +- scripts/manual_fixtures.py | 8 +++++-- scripts/setup.sh | 2 +- scripts/setup_test.sh | 19 ++-------------- scripts/tests_and_coverage.sh | 16 +------------ 13 files changed, 45 insertions(+), 75 deletions(-) delete mode 100644 .markdownlint.yaml create mode 100644 .pymarkdown diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml index eff328926..2b1a004e6 100644 --- a/.github/workflows/verify.yml +++ b/.github/workflows/verify.yml @@ -4,9 +4,8 @@ name: Latest commit env: - CACHE_VERSION: 2 + CACHE_VERSION: 3 DEFAULT_PYTHON: "3.14" - PRE_COMMIT_HOME: ~/.cache/pre-commit VENV: venv on: @@ -45,15 +44,15 @@ jobs: needs: cache name: Prepare steps: - - name: Prepare code checkout and python/pre-commit setup + - name: Prepare code checkout and python/prek(pre-commit) setup id: cache-reuse - uses: plugwise/gh-actions/prepare-python-and-code@v1 + uses: plugwise/gh-actions/prepare-python-and-code@v2 with: cache-key: ${{ needs.cache.outputs.cache-key }} fail-on-miss: false # First time create cache (if not already exists) python-version: ${{ needs.cache.outputs.python-version }} venv-dir: ${{ env.VENV }} - precommit-home: ${{ env.PRE_COMMIT_HOME }} + prek-home: ${{ env.PREK_HOME }} ruff: runs-on: ubuntu-latest @@ -68,12 +67,12 @@ jobs: persist-credentials: false - name: Restore cached environment id: cache-reuse - uses: plugwise/gh-actions/restore-venv@v1 + uses: plugwise/gh-actions/restore-venv@v2 with: cache-key: ${{ needs.cache.outputs.cache-key }} python-version: ${{ needs.cache.outputs.python-version }} venv-dir: ${{ env.VENV }} - precommit-home: ${{ env.PRE_COMMIT_HOME }} + prek-home: ${{ env.PREK_HOME }} - name: Ruff (with fix) run: | . venv-${{ needs.cache.outputs.python-version }}/bin/activate @@ -104,25 +103,20 @@ jobs: uses: actions/checkout@v6 - name: Restore cached environment id: cache-reuse - uses: plugwise/gh-actions/restore-venv@v1 + uses: plugwise/gh-actions/restore-venv@v2 with: cache-key: ${{ needs.cache.outputs.cache-key }} python-version: ${{ needs.cache.outputs.python-version }} venv-dir: ${{ env.VENV }} - precommit-home: ${{ env.PRE_COMMIT_HOME }} + prek-home: ${{ env.PREK_HOME }} - name: Verify commit run: | . venv-${{ needs.cache.outputs.python-version }}/bin/activate - pre-commit run --show-diff-on-failure --color=always --all-files --hook-stage manual pylint - - name: Biome lint - run: | - . venv-${{ needs.cache.outputs.python-version }}/bin/activate - mkdir -p ./tmp && curl -sL "https://github.com/biomejs/biome/releases/latest/download/biome-linux-x64" -o ./tmp/biome && chmod +x ./tmp/biome - pre-commit run --show-diff-on-failure --color=always --all-files --hook-stage manual biome + prek run --show-diff-on-failure --color=always --all-files --hook-stage manual pylint - name: Lint markdown files run: | . venv-${{ needs.cache.outputs.python-version }}/bin/activate - pre-commit run --show-diff-on-failure --color=always --all-files --hook-stage manual markdownlint + prek run --show-diff-on-failure --color=always --all-files --hook-stage manual markdownlint pytest: runs-on: ubuntu-latest @@ -144,13 +138,13 @@ jobs: python-version: ${{ matrix.python-version }} - name: Restore cached environment id: cache-reuse - uses: plugwise/gh-actions/restore-venv@v1 + uses: plugwise/gh-actions/restore-venv@v2 with: fail-on-miss: false # First time create cache (if not already exists) cache-key: ${{ needs.cache.outputs.cache-key }} python-version: ${{ steps.python.outputs.python-version }} # Force to installed python minor venv-dir: ${{ env.VENV }} - precommit-home: ${{ env.PRE_COMMIT_HOME }} + prek-home: ${{ env.PREK_HOME }} - name: Run all tests run: | . venv-${{ steps.python.outputs.python-version }}/bin/activate @@ -177,12 +171,12 @@ jobs: persist-credentials: false - name: Restore cached environment id: cache-reuse - uses: plugwise/gh-actions/restore-venv@v1 + uses: plugwise/gh-actions/restore-venv@v2 with: cache-key: ${{ needs.cache.outputs.cache-key }} python-version: ${{ needs.cache.outputs.python-version }} venv-dir: ${{ env.VENV }} - precommit-home: ${{ env.PRE_COMMIT_HOME }} + prek-home: ${{ env.PREK_HOME }} - name: Run mypy run: | . venv-${{ needs.cache.outputs.python-version }}/bin/activate @@ -222,12 +216,12 @@ jobs: uses: actions/checkout@v6 - name: Restore cached environment id: cache-reuse - uses: plugwise/gh-actions/restore-venv@v1 + uses: plugwise/gh-actions/restore-venv@v2 with: cache-key: ${{ needs.cache.outputs.cache-key }} python-version: ${{ needs.cache.outputs.python-version }} venv-dir: ${{ env.VENV }} - precommit-home: ${{ env.PRE_COMMIT_HOME }} + prek-home: ${{ env.PREK_HOME }} - name: Download all coverage artifacts uses: actions/download-artifact@v7 with: @@ -304,12 +298,12 @@ jobs: uses: actions/checkout@v6 - name: Restore cached environment id: cache-reuse - uses: plugwise/gh-actions/restore-venv@v1 + uses: plugwise/gh-actions/restore-venv@v2 with: cache-key: ${{ needs.cache.outputs.cache-key }} python-version: ${{ needs.cache.outputs.python-version }} venv-dir: ${{ env.VENV }} - precommit-home: ${{ env.PRE_COMMIT_HOME }} + prek-home: ${{ env.PREK_HOME }} - name: Run complexity report (click to view details) run: | . venv-${{ needs.cache.outputs.python-version }}/bin/activate diff --git a/.markdownlint.yaml b/.markdownlint.yaml deleted file mode 100644 index 320406db4..000000000 --- a/.markdownlint.yaml +++ /dev/null @@ -1,2 +0,0 @@ -default: true -MD013: false diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5ffb502d4..0d502e952 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -86,10 +86,6 @@ repos: name: "Setup" entry: /usr/bin/env bash -c 'test -d ./venv || scripts/setup.sh' language: script - - id: setup_test - name: "Setup (extended for testing" - entry: /usr/bin/env bash -c 'test -f ./tmp/biome || scripts/setup_test.sh pre-commit' - language: script - id: userdata name: "Validating userdata" entry: scripts/pre-commit.sh @@ -115,11 +111,8 @@ repos: entry: /usr/bin/env bash -c 'exec env GITHUB_ACTIONS="1" NO_FIXTURES="1" scripts/tests_and_coverage.sh test_and_coverage' language: script pass_filenames: false - - id: biome - name: "Biome (prettier)" - entry: ./tmp/biome check fixtures/ plugwise/ tests/ --files-ignore-unknown=true --no-errors-on-unmatched --json-formatter-indent-width=2 --json-formatter-indent-style=space - language: script - - repo: https://github.com/igorshubovych/markdownlint-cli - rev: v0.47.0 + - repo: https://github.com/jackdewinter/pymarkdown + rev: v0.9.34 hooks: - - id: markdownlint + - id: pymarkdown + name: MarkDown Lint diff --git a/.pymarkdown b/.pymarkdown new file mode 100644 index 000000000..7cdbe9000 --- /dev/null +++ b/.pymarkdown @@ -0,0 +1 @@ +{ "plugins": { "md013": { "enabled": false } } } diff --git a/CHANGELOG.md b/CHANGELOG.md index 97e474824..700af5d32 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,10 @@ ## Ongoing - More code optimizations via PR[#843](https://github.com/plugwise/python-plugwise/pull/843) +- Chores: + - Introduce prek (for pre-commit) & align with v2 gh-actions + - Remove biome (as prettier was reinstated) + - Replace node-based markdownlint with pythonesk library ## v1.11.2 diff --git a/biome.json b/biome.json index 00ec4d1e9..b72e610ee 100644 --- a/biome.json +++ b/biome.json @@ -1,5 +1,10 @@ { "files": { "maxSize": 5000000 + }, + "json": { + "formatter": { + "arrayExpand": "all" + } } } diff --git a/plugwise/legacy/smile.py b/plugwise/legacy/smile.py index 81ed20d90..89e582256 100644 --- a/plugwise/legacy/smile.py +++ b/plugwise/legacy/smile.py @@ -227,7 +227,7 @@ async def set_switch_state( For individual switches, sets the state directly. For group switches, sets the state for each member in the group separately. For switch-locks, sets the lock state using a different data format. - Return the requested state when succesful, the current state otherwise. + Return the requested state when successful, the current state otherwise. """ current_state = self.gw_entities[appl_id]["switches"]["relay"] requested_state = state == STATE_ON diff --git a/plugwise/smile.py b/plugwise/smile.py index 62effac66..6acb4233a 100644 --- a/plugwise/smile.py +++ b/plugwise/smile.py @@ -406,7 +406,7 @@ async def set_switch_state( For individual switches, sets the state directly. For group switches, sets the state for each member in the group separately. For switch-locks, sets the lock state using a different data format. - Return the requested state when succesful, the current state otherwise. + Return the requested state when successful, the current state otherwise. """ model_type = cast(SwitchType, model) current_state = self.gw_entities[appl_id]["switches"][model_type] diff --git a/requirements_commit.txt b/requirements_commit.txt index 645712841..8fb2da2d3 100644 --- a/requirements_commit.txt +++ b/requirements_commit.txt @@ -5,6 +5,6 @@ coverage ruff mypy -pre-commit +prek pylint pylint_strict_informational==0.1 diff --git a/scripts/manual_fixtures.py b/scripts/manual_fixtures.py index 5a44446a7..f7a842318 100755 --- a/scripts/manual_fixtures.py +++ b/scripts/manual_fixtures.py @@ -36,8 +36,12 @@ def json_writer(manual_name: str, output: dict) -> None: adam_multiple_devices_per_zone = base.copy() # Change schedule to not present for "446ac08dd04d4eff8ac57489757b7314" -adam_multiple_devices_per_zone["446ac08dd04d4eff8ac57489757b7314"]["available_schedules"] = [] -adam_multiple_devices_per_zone["446ac08dd04d4eff8ac57489757b7314"]["select_schedule"] = None +adam_multiple_devices_per_zone["446ac08dd04d4eff8ac57489757b7314"][ + "available_schedules" +] = [] +adam_multiple_devices_per_zone["446ac08dd04d4eff8ac57489757b7314"][ + "select_schedule" +] = None json_writer("m_adam_multiple_devices_per_zone", adam_multiple_devices_per_zone) diff --git a/scripts/setup.sh b/scripts/setup.sh index 00073f8d6..505cb76e3 100755 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -20,4 +20,4 @@ fi uv pip install --upgrade -e . -r requirements_commit.txt -c https://raw.githubusercontent.com/home-assistant/core/dev/homeassistant/package_constraints.txt -r https://raw.githubusercontent.com/home-assistant/core/dev/requirements_test_pre_commit.txt # Install pre-commit hook -pre-commit install +prek install --install-hooks diff --git a/scripts/setup_test.sh b/scripts/setup_test.sh index 2120fe14c..9874f02e3 100755 --- a/scripts/setup_test.sh +++ b/scripts/setup_test.sh @@ -2,8 +2,6 @@ # 20250613 Copied from HA-core and shell-check adjusted and modified for local use set -e -my_path=$(git rev-parse --show-toplevel) - if [ -z "$VIRTUAL_ENV" ]; then if [ -x "$(command -v uv)" ]; then uv venv venv @@ -23,20 +21,7 @@ mkdir -p ./tmp # Install test requirements uv pip install --upgrade -e . -r requirements_test.txt -c https://raw.githubusercontent.com/home-assistant/core/dev/homeassistant/package_constraints.txt -r https://raw.githubusercontent.com/home-assistant/core/dev/requirements_test.txt -r https://raw.githubusercontent.com/home-assistant/core/dev/requirements_test_pre_commit.txt -# Prepare biomejs -echo "Fetching/updating biome cli" -arch=$(uname -m) -case "$arch" in - aarch64|arm64) use_arch="darwin-arm64" ;; - x86_64) use_arch="linux-x64" ;; - *) echo "Unsupported arch for biome cli version: $arch"; exit 2 ;; -esac -curl -sL "https://github.com/biomejs/biome/releases/latest/download/biome-${use_arch}" -o "${my_path}/tmp/biome" - -# Make biome executable (if necessary) -chmod +x "${my_path}/tmp/biome" - -# Install pre-commit hook unless running from within pre-commit +# Install prek hook unless running from within pre-commit if [ "$#" -eq 0 ]; then - pre-commit install + prek install --install-hooks fi diff --git a/scripts/tests_and_coverage.sh b/scripts/tests_and_coverage.sh index f4a1b0742..42aca60ec 100755 --- a/scripts/tests_and_coverage.sh +++ b/scripts/tests_and_coverage.sh @@ -44,15 +44,9 @@ handle_command_error() { fi } -biome_format() { - ./tmp/biome check fixtures/ plugwise/ tests/ --files-ignore-unknown=true --no-errors-on-unmatched --indent-width=2 --indent-style=space --write - handle_command_error "biome formatting" -} - # Install/update dependencies -pre-commit install -pre-commit install-hooks uv pip install -r requirements_test.txt -r requirements_commit.txt +prek install --install-hooks set +u @@ -63,9 +57,6 @@ if [ -z "${GITHUB_ACTIONS}" ] || [ "$1" == "test_and_coverage" ] ; then fi if [ -z "${GITHUB_ACTIONS}" ] || [ "$1" == "linting" ] ; then - echo "... biome-ing (prettier) ..." - biome_format - echo "... ruff checking ..." ruff check plugwise/ tests/ handle_command_error "ruff checking" @@ -82,12 +73,7 @@ if [ -z "${GITHUB_ACTIONS}" ] || [ "$1" == "linting" ] ; then handle_command_error "mypy validation" fi -# As to not generated fixtures, leaving biome to re-do them -# so no auto-generation during github run of testing -# Creating todo #313 to 'gracefully' do this on merge on github action if [ -z "${GITHUB_ACTIONS}" ] || [ "$1" == "fixtures" ] ; then echo "... Crafting manual fixtures ..." PYTHONPATH=$(pwd) python3 scripts/manual_fixtures.py - echo "... (re) biome-ing (prettier) ..." - biome_format fi From e0f33d053550f3f320c315cd6d2ef06eb7bdaffd Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Mon, 12 Jan 2026 17:24:10 +0100 Subject: [PATCH 2/4] Remove stale biome config --- biome.json | 10 ---------- 1 file changed, 10 deletions(-) delete mode 100644 biome.json diff --git a/biome.json b/biome.json deleted file mode 100644 index b72e610ee..000000000 --- a/biome.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "files": { - "maxSize": 5000000 - }, - "json": { - "formatter": { - "arrayExpand": "all" - } - } -} From 0901f8983578669b7e0a023d5749c27d762c9903 Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Mon, 12 Jan 2026 17:47:45 +0100 Subject: [PATCH 3/4] CI fix --- .github/workflows/verify.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml index 2b1a004e6..3ecc5b7ed 100644 --- a/.github/workflows/verify.yml +++ b/.github/workflows/verify.yml @@ -116,7 +116,7 @@ jobs: - name: Lint markdown files run: | . venv-${{ needs.cache.outputs.python-version }}/bin/activate - prek run --show-diff-on-failure --color=always --all-files --hook-stage manual markdownlint + prek run --show-diff-on-failure --color=always --all-files --hook-stage manual pymarkdown pytest: runs-on: ubuntu-latest From 371f99e2cb4afd8bf8c347034d353efc7865f0b8 Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Wed, 14 Jan 2026 17:23:28 +0100 Subject: [PATCH 4/4] CP review --- CHANGELOG.md | 2 +- requirements_commit.txt | 2 +- scripts/setup.sh | 2 +- scripts/setup_test.sh | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 700af5d32..0c1df4ede 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ - Chores: - Introduce prek (for pre-commit) & align with v2 gh-actions - Remove biome (as prettier was reinstated) - - Replace node-based markdownlint with pythonesk library + - Replace node-based markdownlint with pythonic library ## v1.11.2 diff --git a/requirements_commit.txt b/requirements_commit.txt index 8fb2da2d3..b88fee07b 100644 --- a/requirements_commit.txt +++ b/requirements_commit.txt @@ -5,6 +5,6 @@ coverage ruff mypy -prek +prek>=0.2.27 pylint pylint_strict_informational==0.1 diff --git a/scripts/setup.sh b/scripts/setup.sh index 505cb76e3..75669c78e 100755 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -19,5 +19,5 @@ fi # Install commit requirements uv pip install --upgrade -e . -r requirements_commit.txt -c https://raw.githubusercontent.com/home-assistant/core/dev/homeassistant/package_constraints.txt -r https://raw.githubusercontent.com/home-assistant/core/dev/requirements_test_pre_commit.txt -# Install pre-commit hook +# Install prek/pre-commit hook prek install --install-hooks diff --git a/scripts/setup_test.sh b/scripts/setup_test.sh index 9874f02e3..0490da6d2 100755 --- a/scripts/setup_test.sh +++ b/scripts/setup_test.sh @@ -21,7 +21,7 @@ mkdir -p ./tmp # Install test requirements uv pip install --upgrade -e . -r requirements_test.txt -c https://raw.githubusercontent.com/home-assistant/core/dev/homeassistant/package_constraints.txt -r https://raw.githubusercontent.com/home-assistant/core/dev/requirements_test.txt -r https://raw.githubusercontent.com/home-assistant/core/dev/requirements_test_pre_commit.txt -# Install prek hook unless running from within pre-commit +# Install prek hook unless running from within prek/pre-commit if [ "$#" -eq 0 ]; then prek install --install-hooks fi