Skip to content
Merged

Py314 #356

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
60 changes: 0 additions & 60 deletions .github/actions/restore-venv/action.yml

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
name: Latest release

env:
CACHE_VERSION: 21
DEFAULT_PYTHON: "3.13"
CACHE_VERSION: 22
DEFAULT_PYTHON: "3.14"

# Only run on merges
on:
Expand Down
119 changes: 45 additions & 74 deletions .github/workflows/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
name: Latest commit

env:
CACHE_VERSION: 5
DEFAULT_PYTHON: "3.13"
PRE_COMMIT_HOME: ${{ github.workspace }}/.cache/pre-commit
CACHE_VERSION: 1
DEFAULT_PYTHON: "3.14"
PRE_COMMIT_HOME: ~/.cache/pre-commit
VENV: venv

on:
Expand All @@ -32,30 +32,26 @@ jobs:
uses: actions/setup-python@v6
with:
python-version: ${{ env.DEFAULT_PYTHON }}
- name: Fetch HA pyproject
id: core-version
run: wget -O ha_pyproject.toml "https://raw.githubusercontent.com/home-assistant/core/refs/heads/dev/pyproject.toml"
- name: Compute cache key
id: set-key
run: echo "cache-key=${{ runner.os }}-venv-cache-${{ env.CACHE_VERSION }}-${{ steps.python.outputs.python-version }}-${{ hashFiles('pyproject.toml', 'requirements_commit.txt', 'requirements_test.txt', '.pre-commit-config.yaml') }}" >> "$GITHUB_OUTPUT"
run: echo "cache-key=${{ runner.os }}-${{ env.CACHE_VERSION }}-${{ hashFiles('pyproject.toml', 'requirements_test.txt', '.pre-commit-config.yaml') }}" >> "$GITHUB_OUTPUT"

# Prepare default python version environment
prepare:
runs-on: ubuntu-latest
needs: cache
name: Prepare
steps:
- name: Check out committed code
uses: actions/checkout@v5
- name: Set up Python ${{ needs.cache.outputs.python-version }}
id: python
uses: actions/setup-python@v6
with:
python-version: ${{ needs.cache.outputs.python-version }}
- name: Create or reuse cache
- name: Prepare code checkout and python/pre-commit setup
id: cache-reuse
uses: ./.github/actions/restore-venv
uses: plugwise/gh-actions/prepare-python-and-code@v1
with:
cache-key: ${{ needs.cache.outputs.cache-key }}
fail-on-miss: false # First time create cache (if not already exists)
python-version: ${{ steps.python.outputs.python-version }}
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 }}

Expand All @@ -70,33 +66,28 @@ jobs:
uses: actions/checkout@v5
with:
persist-credentials: false
- name: Set up Python ${{ needs.cache.outputs.python-version }}
id: python
uses: actions/setup-python@v6
with:
python-version: ${{ needs.cache.outputs.python-version }}
- name: Create or reuse cache
- name: Restore cached environment
id: cache-reuse
uses: ./.github/actions/restore-venv
uses: plugwise/gh-actions/restore-venv@v1
with:
cache-key: ${{ needs.cache.outputs.cache-key }}
python-version: ${{ steps.python.outputs.python-version }}
python-version: ${{ needs.cache.outputs.python-version }}
venv-dir: ${{ env.VENV }}
precommit-home: ${{ env.PRE_COMMIT_HOME }}
- name: Ruff (check)
- name: Ruff (with fix)
run: |
. venv/bin/activate
. venv-${{ needs.cache.outputs.python-version }}/bin/activate
ruff check plugwise_usb/ tests/
- name: If needed, commit ruff changes to the pull request
if: failure()
run: |
. venv/bin/activate
. venv-${{ needs.cache.outputs.python-version }}/bin/activate
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_PYPLUSB }}@github.com/$GITHUB_REPOSITORY
git checkout $GITHUB_HEAD_REF
git commit -am "fixup: ${GITHUB_REF##*/} Python code reformatted using Ruff"
git commit -am "fixup: ${GITHUB_REF##*/} Python code fixed using Ruff"
git push origin ${GITHUB_REF##*/}

commitcheck:
Expand All @@ -111,31 +102,26 @@ jobs:
steps:
- name: Check out committed code
uses: actions/checkout@v5
- name: Set up Python ${{ needs.cache.outputs.python-version }}
id: python
uses: actions/setup-python@v6
with:
python-version: ${{ needs.cache.outputs.python-version }}
- name: Create or reuse cache
- name: Restore cached environment
id: cache-reuse
uses: ./.github/actions/restore-venv
uses: plugwise/gh-actions/restore-venv@v1
with:
cache-key: ${{ needs.cache.outputs.cache-key }}
python-version: ${{ steps.python.outputs.python-version }}
python-version: ${{ needs.cache.outputs.python-version }}
venv-dir: ${{ env.VENV }}
precommit-home: ${{ env.PRE_COMMIT_HOME }}
- name: Verify commit
run: |
. venv/bin/activate
. 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/bin/activate
# mkdir -p ./tmp && curl -sL "https://github.com/biomejs/biome/releases/download/%40biomejs%2Fbiome%402.0.0/biome-linux-x64" -o ./tmp/biome && chmod +x ./tmp/biome
# . 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
- name: Lint markdown files
run: |
. venv/bin/activate
. venv-${{ needs.cache.outputs.python-version }}/bin/activate
pre-commit run --show-diff-on-failure --color=always --all-files --hook-stage manual markdownlint

pytest:
Expand All @@ -147,7 +133,7 @@ jobs:
- commitcheck
strategy:
matrix:
python-version: ["3.13"]
python-version: ["3.14", "3.13"]
steps:
- name: Check out committed code
uses: actions/checkout@v5
Expand All @@ -156,18 +142,18 @@ jobs:
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
- name: Create or reuse cache
- name: Restore cached environment
id: cache-reuse
uses: ./.github/actions/restore-venv
uses: plugwise/gh-actions/restore-venv@v1
with:
cache-key: ${{ needs.cache.outputs.cache-key }}-pytest-matrix-${{ matrix.python-version }}
fail-on-miss: false # First time create cache (if not already exists)
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 }}
- name: Run all tests
run: |
. venv/bin/activate
. venv-${{ steps.python.outputs.python-version }}/bin/activate
pytest --log-level info tests/*.py --cov='.'
- name: Upload coverage artifact
uses: actions/upload-artifact@v4
Expand All @@ -190,23 +176,18 @@ jobs:
uses: actions/checkout@v5
with:
persist-credentials: false
- name: Set up Python ${{ needs.cache.outputs.python-version }}
id: python
uses: actions/setup-python@v6
with:
python-version: ${{ needs.cache.outputs.python-version }}
- name: Create or reuse cache
- name: Restore cached environment
id: cache-reuse
uses: ./.github/actions/restore-venv
uses: plugwise/gh-actions/restore-venv@v1
with:
cache-key: ${{ needs.cache.outputs.cache-key }}
python-version: ${{ steps.python.outputs.python-version }}
python-version: ${{ needs.cache.outputs.python-version }}
venv-dir: ${{ env.VENV }}
precommit-home: ${{ env.PRE_COMMIT_HOME }}
- name: Run mypy
run: |
. venv/bin/activate
uv pip list | grep -i mypy
. venv-${{ needs.cache.outputs.python-version }}/bin/activate
pip list | grep -i mypy
mypy plugwise_usb/

# Check shellscripts
Expand Down Expand Up @@ -240,17 +221,12 @@ jobs:
steps:
- name: Check out committed code
uses: actions/checkout@v5
- name: Set up Python ${{ needs.cache.outputs.python-version }}
id: python
uses: actions/setup-python@v6
with:
python-version: ${{ needs.cache.outputs.python-version }}
- name: Create or reuse cache
- name: Restore cached environment
id: cache-reuse
uses: ./.github/actions/restore-venv
uses: plugwise/gh-actions/restore-venv@v1
with:
cache-key: ${{ needs.cache.outputs.cache-key }}
python-version: ${{ steps.python.outputs.python-version }}
python-version: ${{ needs.cache.outputs.python-version }}
venv-dir: ${{ env.VENV }}
precommit-home: ${{ env.PRE_COMMIT_HOME }}
- name: Download all coverage artifacts
Expand All @@ -261,7 +237,7 @@ jobs:
path: ${{ github.workspace }}/artifacts
- name: Combine coverage results
run: |
. venv/bin/activate
. venv-${{ needs.cache.outputs.python-version }}/bin/activate
coverage combine artifacts/.coverage*
#coverage report --fail-under=80 ## plugwise is at 94, set to 80 for plugwise_usb
echo "***"
Expand Down Expand Up @@ -333,21 +309,16 @@ jobs:
steps:
- name: Check out committed code
uses: actions/checkout@v5
- name: Set up Python ${{ needs.cache.outputs.python-version }}
id: python
uses: actions/setup-python@v6
with:
python-version: ${{ needs.cache.outputs.python-version }}
- name: Create or reuse cache
- name: Restore cached environment
id: cache-reuse
uses: ./.github/actions/restore-venv
uses: plugwise/gh-actions/restore-venv@v1
with:
cache-key: ${{ needs.cache.outputs.cache-key }}
python-version: ${{ steps.python.outputs.python-version }}
python-version: ${{ needs.cache.outputs.python-version }}
venv-dir: ${{ env.VENV }}
precommit-home: ${{ env.PRE_COMMIT_HOME }}
- name: Run complexity report (click to view details)
run: |
. venv/bin/activate
. venv-${{ needs.cache.outputs.python-version }}/bin/activate
echo "Showing complexity higher or equal to 'C'"
radon cc plugwise/ tests/ -s -nc --no-assert
radon cc plugwise_usb/ tests/ -s -nc --no-assert
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
default_language_version:
# force all unspecified python hooks to run python3
python: python3.13
python: default

repos:
# Run manually in CI skipping the branch checks
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## Ongoing

- Test/validate for Python 3.14

## v0.47.1 - 2025-09-27

- PR [351](https://github.com/plugwise/python-plugwise-usb/pull/351): Avoid unintentional overwrite of nodetype.cache file at start/reload.
Expand Down
7 changes: 4 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3.14",
"Programming Language :: Python :: 3.13",
"Topic :: Home Automation",
]
Expand Down Expand Up @@ -56,7 +57,7 @@ include = ["plugwise_usb*"]
##

[tool.pylint.MAIN]
py-version = "3.13"
py-version = "3.14"
# Use a conservative default here; 2 should speed up most setups and not hurt
# any too bad. Override on command line as appropriate.
jobs = 2
Expand Down Expand Up @@ -389,7 +390,7 @@ max-line-length-suggestions = 72


[tool.mypy]
python_version = "3.13"
python_version = "3.14"
show_error_codes = true
follow_imports = "silent"
ignore_missing_imports = true
Expand Down Expand Up @@ -419,7 +420,7 @@ omit= [
]

[tool.ruff]
target-version = "py313"
target-version = "py314"

lint.select = [
"B002", # Python does not support the unary prefix increment
Expand Down