Skip to content
Merged
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
36 changes: 19 additions & 17 deletions .github/workflows/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
name: Latest commit

env:
CACHE_VERSION: 24
CACHE_VERSION: 1
DEFAULT_PYTHON: "3.13"
PRE_COMMIT_HOME: ~/.cache/pre-commit

Expand All @@ -13,7 +13,7 @@ on:
- cron: "2 4 * * 0" # weekly
workflow_dispatch:
push:
pull_request:
#pull_request:

jobs:
# Prepare default python version environment
Expand Down Expand Up @@ -48,8 +48,9 @@ jobs:
pip install virtualenv --upgrade
python -m venv venv
. venv/bin/activate
pip install -U pip setuptools wheel
pip install -r requirements_test.txt -r requirements_commit.txt
pip install uv
uv pip install -U pip setuptools wheel
uv pip install -r requirements_test.txt -r requirements_commit.txt
- name: Restore pre-commit environment from cache
id: cache-precommit
uses: actions/cache@v4
Expand Down Expand Up @@ -97,20 +98,15 @@ jobs:
- name: Ruff (check)
run: |
. venv/bin/activate
#ruff plugwise_usb/*py tests/*py
echo "***"
echo "***"
echo "Code is not up to par for ruff, skipping"
echo "***"
echo "***"
ruff check plugwise_usb/ tests/
- name: If needed, commit ruff changes to the pull request
if: failure()
run: |
. venv/bin/activate
ruff --fix plugwise_usb/*py tests/*py
ruff format plugwise_usb/ tests/
git config --global user.name 'autoruff'
git config --global user.email 'plugwise_usb@users.noreply.github.com'
git remote set-url origin https://x-access-token:${{ secrets.PAT_CT }}@github.com/$GITHUB_REPOSITORY
git remote set-url origin https://x-access-token:${{ secrets.PAT_CT_PYPLUSB }}@github.com/$GITHUB_REPOSITORY
git checkout $GITHUB_HEAD_REF
git commit -am "fixup: ${GITHUB_REF##*/} Python code reformatted using Ruff"
git push origin ${GITHUB_REF##*/}
Expand Down Expand Up @@ -161,6 +157,11 @@ jobs:
run: |
. venv/bin/activate
pre-commit run --show-diff-on-failure --color=always --all-files --hook-stage manual pylint
- name: Biome lint
run: |
. venv/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
- name: Lint markdown files
run: |
. venv/bin/activate
Expand Down Expand Up @@ -199,11 +200,12 @@ jobs:
run: |
python -m venv venv
. venv/bin/activate
pip install -U pip setuptools wheel
pip install uv
uv pip install -U pip setuptools wheel
#pip install -r requirements_test.txt
# 20220124 Mimic setup_test.sh
pip install --upgrade -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
pip install --upgrade pytest-asyncio
uv pip install --upgrade -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
uv pip install --upgrade pytest-asyncio

pytest:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -279,11 +281,11 @@ jobs:
- name: Run mypy
run: |
. venv/bin/activate
pip list | grep -i mypy
uv pip list | grep -i mypy
#mypy plugwise_usb/
echo "***"
echo "***"
echo "Code is not up to par for mypy, skipping"
echo "Code is not up to par for mypy, skipping - see #171"
echo "***"
echo "***"

Expand Down
70 changes: 44 additions & 26 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,47 +1,49 @@
# For pre-commit.ci
ci:
# Defer autoupdate to quarterly (there is no 'off' button) to have renovate pick up first
autoupdate_schedule: quarterly
skip: [pylint, markdownlint, testing]
submodules: true

default_language_version:
# force all unspecified python hooks to run python3
python: python3.13

repos:
# Run manually in CI skipping the branch checks
# RUFF disabled, code is not up to par with HA standards
# - repo: https://github.com/astral-sh/ruff-pre-commit
# rev: v0.1.7
# hooks:
# - id: ruff
# args:
# - --fix

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.11.13
hooks:
- id: ruff
name: "Ruff check"
args:
- --fix
- id: ruff-format
name: "Ruff format"
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: check-executables-have-shebangs
name: "Checking executables"
stages: [manual]
- id: no-commit-to-branch
name: "Verifying branch"
args:
- --branch=main
- repo: https://github.com/asottile/pyupgrade
rev: v3.20.0
hooks:
- id: pyupgrade
name: "Checking pyupgrade"
args: [--py39-plus]
# Moved codespell configuration to setup.cfg as per 'all-files' issues not reading args
- repo: https://github.com/codespell-project/codespell
rev: v2.4.1
hooks:
- id: codespell
name: "Check Code Spelling"
args:
- --ignore-words-list=aiport,astroid,checkin,currenty,hass,iif,incomfort,lookin,nam,NotIn # Previous list, remove before merge # - ignore-words-list = additionals,alle,alot,ba,bre,bund,currenty,datas,dof,dur,ether,farenheit,falsy,fo,haa,hass,hist,iam,iff,iif,incomfort,ines,ist,leeg,lightsensor,mut,nam,nd,pres,pullrequests,referer,resset,rime,ser,serie,sur,te,technik,ue,uint,unsecure,visability,wan,wanna,withing,zar
- --skip="./.*,*.csv,*.json,*.ambr"
- --quiet-level=2
exclude_types: [csv, json]
- repo: https://github.com/PyCQA/bandit
rev: 1.8.5
hooks:
- id: bandit
name: "Bandit checking"
args:
- --quiet
- --format=custom
Expand All @@ -51,57 +53,73 @@ repos:
rev: v1.37.1
hooks:
- id: yamllint
name: "YAML linting"
- repo: https://github.com/biomejs/pre-commit
rev: v1.9.4
hooks:
- id: biome-lint
additional_dependencies: ["@biomejs/biome@1.8.3"]
name: "Verifying/updating code with biome (improved prettier)"
additional_dependencies: ["@biomejs/biome@1.8.3"]
- repo: https://github.com/cdce8p/python-typing-update
rev: v0.7.2
hooks:
# Run `python-typing-update` hook manually from time to time
# to update python typing syntax.
# Will require manual work, before submitting changes!
- id: python-typing-update
name: "Python typing"
stages: [manual]
args:
- --py39-plus
- --force
- --keep-updates
files: ^(plugwise_usb|tests)/.+\.py$
- repo: https://github.com/shellcheck-py/shellcheck-py
rev: v0.10.0.1
hooks:
- id: shellcheck
name: "Shell checking"
args:
- --external-sources
- repo: local
hooks:
# Run mypy through our wrapper script in order to get the possible
# pyenv and/or virtualenv activated; it may not have been e.g. if
# committing from a GUI tool that was not launched from an activated
# shell.
- id: userdata
name: userdata
entry: scripts/pre-commit.sh
- id: setup
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
types: [python]
pass_filenames: false
- id: mypy
name: mypy
name: "Running MyPy"
entry: scripts/run-in-env.sh mypy
language: script
types: [python]
require_serial: true
files: ^plugwise_usb/$
- id: pylint
name: pylint
name: "PyLinting"
entry: scripts/run-in-env.sh pylint -j 0
language: script
types: [python]
files: ^plugwise_usb/.+\.py$
- id: testing
name: "Local Testing - Performing Tests"
name: "Performing Tests"
# yamllint disable-line rule:line-length
entry: /usr/bin/env bash -c 'exec env GITHUB_ACTIONS="1" scripts/tests_and_coverage.sh test_and_coverage'
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 plugwise_usb/ 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.45.0
hooks:
- id: markdownlint
name: "Markdown linting"
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Ongoing

- PR [#261](https://github.com/plugwise/python-plugwise-usb/pull/261): Sense: bugfix parsing of humidity value as an unsigned int
- Maintenance chores and re-instatement of ruff, deprecate pre-commit cloud runs (just leveraging renovate)

## v0.44.3 - 2025-06-12

Expand Down
Loading
Loading