Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 18 additions & 24 deletions .github/workflows/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link

Copilot AI Jan 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PREK_HOME environment variable is referenced throughout the workflow but is never defined in the env section. This will cause the prek-home parameter to be empty when passed to the GitHub Actions, potentially breaking the caching mechanism for prek.

Suggested change
VENV: venv
VENV: venv
PREK_HOME: .prek

Copilot uses AI. Check for mistakes.

on:
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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 pymarkdown

pytest:
runs-on: ubuntu-latest
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions .markdownlint.yaml

This file was deleted.

15 changes: 4 additions & 11 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
1 change: 1 addition & 0 deletions .pymarkdown
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "plugins": { "md013": { "enabled": false } } }
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link

Copilot AI Jan 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The word "pythonesk" should be "Pythonic" or "Python-based" for proper English. "Pythonic" is the standard term for code or libraries that follow Python conventions and style.

Suggested change
- Replace node-based markdownlint with pythonesk library
- Replace node-based markdownlint with Python-based library

Copilot uses AI. Check for mistakes.

## v1.11.2

Expand Down
5 changes: 0 additions & 5 deletions biome.json

This file was deleted.

2 changes: 1 addition & 1 deletion plugwise/legacy/smile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion plugwise/smile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion requirements_commit.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
coverage
ruff
mypy
pre-commit
prek
pylint
pylint_strict_informational==0.1
8 changes: 6 additions & 2 deletions scripts/manual_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion scripts/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link

Copilot AI Jan 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment "Install pre-commit hook" should be updated to "Install prek hook" to reflect the migration from pre-commit to prek.

Suggested change
# Install pre-commit hook
# Install prek hook

Copilot uses AI. Check for mistakes.
pre-commit install
prek install --install-hooks
19 changes: 2 additions & 17 deletions scripts/setup_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Copy link

Copilot AI Jan 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment "Install prek hook unless running from within pre-commit" is outdated and should refer to prek instead of pre-commit for consistency with the migration.

Copilot uses AI. Check for mistakes.
if [ "$#" -eq 0 ]; then
pre-commit install
prek install --install-hooks
fi
16 changes: 1 addition & 15 deletions scripts/tests_and_coverage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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"
Expand All @@ -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
Loading