From 1105c131defb59472a087aaf1cc017e5d6929e8b Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Tue, 7 Oct 2025 23:27:44 +0200 Subject: [PATCH 1/3] Use common caching actions from repo - bump py314 --- .github/actions/restore-venv/action.yml | 60 --------------- .github/workflows/merge.yml | 4 +- .github/workflows/verify.yml | 99 ++++++++----------------- .pre-commit-config.yaml | 2 +- CHANGELOG.md | 4 + pyproject.toml | 7 +- 6 files changed, 43 insertions(+), 133 deletions(-) delete mode 100644 .github/actions/restore-venv/action.yml diff --git a/.github/actions/restore-venv/action.yml b/.github/actions/restore-venv/action.yml deleted file mode 100644 index 0c920a75f..000000000 --- a/.github/actions/restore-venv/action.yml +++ /dev/null @@ -1,60 +0,0 @@ -name: "Restore venv and pre-commit from cache" -description: "Restores the venv and pre-commit cache or fails" - -inputs: - python-version: - required: true - venv-dir: - required: true - precommit-home: - required: true - cache-key: - required: true - - fail-on-miss: - required: false - default: "true" # DefauLt fail if not available - -runs: - using: "composite" - steps: - - name: Create or reuse cache - id: cache-create - uses: actions/cache@v4 - with: - path: | - ${{ inputs.venv-dir }} - ${{ inputs.precommit-home }} - key: ${{ inputs.cache-key }} - - name: Create Python virtual environment - if: ${{ steps.cache-create.outputs.cache-hit != 'true' }} - shell: bash - run: | - pip install virtualenv --upgrade - python -m venv venv - . venv/bin/activate - pip install uv - uv pip install -U pip setuptools wheel - # 20220124 Mimic setup_test.sh - uv pip install --upgrade -r requirements_commit.txt -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 - - name: Install pre-commit dependencies - if: ${{ steps.cache-create.outputs.cache-hit != 'true' }} - shell: bash - run: | - . venv/bin/activate - pre-commit install-hooks - - name: Save cache if (purposely) created - if: ${{ inputs.fail-on-miss == 'false' && steps.cache-create.outputs.cache-hit != 'true' }} - uses: actions/cache/save@v4 - with: - key: ${{ inputs.cache-key }} - path: | - ${{ inputs.venv-dir }} - ${{ inputs.precommit-home }} - - name: Fail job if Python cache restore failed - if: ${{ inputs.fail-on-miss == 'true' && steps.cache-create.outputs.cache-hit != 'true' }} - shell: bash - run: | - echo "Failed to restore cache for ${{ inputs.python-version}} virtual environment from cache" - exit 1 diff --git a/.github/workflows/merge.yml b/.github/workflows/merge.yml index 15e74d8f3..4bcb56837 100644 --- a/.github/workflows/merge.yml +++ b/.github/workflows/merge.yml @@ -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: diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml index 9d28a3a2a..ff1982377 100644 --- a/.github/workflows/verify.yml +++ b/.github/workflows/verify.yml @@ -4,8 +4,8 @@ name: Latest commit env: - CACHE_VERSION: 5 - DEFAULT_PYTHON: "3.13" + CACHE_VERSION: 6 + DEFAULT_PYTHON: "3.14" PRE_COMMIT_HOME: ${{ github.workspace }}/.cache/pre-commit VENV: venv @@ -32,9 +32,12 @@ 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 }}-venv-cache-${{ env.CACHE_VERSION }}-${{ steps.python.outputs.python-version }}-${{ hashFiles('pyproject.toml', 'requirements_test.txt', '.pre-commit-config.yaml') }}" >> "$GITHUB_OUTPUT" # Prepare default python version environment prepare: @@ -42,20 +45,12 @@ jobs: 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.python.outputs.python-version }} venv-dir: ${{ env.VENV }} precommit-home: ${{ env.PRE_COMMIT_HOME }} @@ -70,20 +65,15 @@ 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.python.outputs.python-version }} venv-dir: ${{ env.VENV }} precommit-home: ${{ env.PRE_COMMIT_HOME }} - - name: Ruff (check) + - name: Ruff (with fix) run: | . venv/bin/activate ruff check plugwise_usb/ tests/ @@ -111,17 +101,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/ghactions/restore-venv@v1 with: cache-key: ${{ needs.cache.outputs.cache-key }} - python-version: ${{ steps.python.outputs.python-version }} + python-version: ${{ needs.python.outputs.python-version }} venv-dir: ${{ env.VENV }} precommit-home: ${{ env.PRE_COMMIT_HOME }} - name: Verify commit @@ -131,7 +116,7 @@ jobs: # - 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 +# 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: | @@ -147,22 +132,17 @@ jobs: - commitcheck strategy: matrix: - python-version: ["3.13"] + python-version: ["3.14", "3.13"] steps: - name: Check out committed code uses: actions/checkout@v5 - - name: Set up Python ${{ matrix.python-version }} - id: python - 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/ghactions/restore-venv@v1 with: + fail-on-miss: false # First time create cache (if not already exists) cache-key: ${{ needs.cache.outputs.cache-key }}-pytest-matrix-${{ matrix.python-version }} - fail-on-miss: false # First time create cache (if not already exists) - python-version: ${{ steps.python.outputs.python-version }} # Force to installed python minor + python-version: ${{ needs.python.outputs.python-version }} # Force to installed python minor venv-dir: ${{ env.VENV }} precommit-home: ${{ env.PRE_COMMIT_HOME }} - name: Run all tests @@ -190,17 +170,12 @@ 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 with: cache-key: ${{ needs.cache.outputs.cache-key }} - python-version: ${{ steps.python.outputs.python-version }} + python-version: ${{ needs.python.outputs.python-version }} venv-dir: ${{ env.VENV }} precommit-home: ${{ env.PRE_COMMIT_HOME }} - name: Run mypy @@ -240,17 +215,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.python.outputs.python-version }} venv-dir: ${{ env.VENV }} precommit-home: ${{ env.PRE_COMMIT_HOME }} - name: Download all coverage artifacts @@ -333,21 +303,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.python.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 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 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1152f783e..997fd2b1b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ default_language_version: # force all unspecified python hooks to run python3 - python: python3.13 + python: python3.14 repos: # Run manually in CI skipping the branch checks diff --git a/CHANGELOG.md b/CHANGELOG.md index ed92dd003..827b77ca6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/pyproject.toml b/pyproject.toml index 1640eeb98..284719c65 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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", ] @@ -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 @@ -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 @@ -419,7 +420,7 @@ omit= [ ] [tool.ruff] -target-version = "py313" +target-version = "py314" lint.select = [ "B002", # Python does not support the unary prefix increment From b1a08d8c92be62dc0c53e3a8a8a4be59e146b578 Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Tue, 7 Oct 2025 23:40:09 +0200 Subject: [PATCH 2/3] Use matrix version --- .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 ff1982377..66a2a92de 100644 --- a/.github/workflows/verify.yml +++ b/.github/workflows/verify.yml @@ -142,7 +142,7 @@ jobs: with: fail-on-miss: false # First time create cache (if not already exists) cache-key: ${{ needs.cache.outputs.cache-key }}-pytest-matrix-${{ matrix.python-version }} - python-version: ${{ needs.python.outputs.python-version }} # Force to installed python minor + python-version: ${{ matrix.python-version }} # Force to installed python minor venv-dir: ${{ env.VENV }} precommit-home: ${{ env.PRE_COMMIT_HOME }} - name: Run all tests From 6e30c42d5954cb98f447029d08f6e176894f4d88 Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Wed, 8 Oct 2025 09:55:23 +0200 Subject: [PATCH 3/3] Align with python-plugwise --- .github/workflows/verify.yml | 56 ++++++++++++++++++++---------------- .pre-commit-config.yaml | 2 +- 2 files changed, 32 insertions(+), 26 deletions(-) diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml index 66a2a92de..34a6e1787 100644 --- a/.github/workflows/verify.yml +++ b/.github/workflows/verify.yml @@ -4,9 +4,9 @@ name: Latest commit env: - CACHE_VERSION: 6 + CACHE_VERSION: 1 DEFAULT_PYTHON: "3.14" - PRE_COMMIT_HOME: ${{ github.workspace }}/.cache/pre-commit + PRE_COMMIT_HOME: ~/.cache/pre-commit VENV: venv on: @@ -37,7 +37,7 @@ jobs: 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_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: @@ -49,8 +49,9 @@ jobs: id: cache-reuse 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: ${{ needs.python.outputs.python-version }} + python-version: ${{ needs.cache.outputs.python-version }} venv-dir: ${{ env.VENV }} precommit-home: ${{ env.PRE_COMMIT_HOME }} @@ -70,23 +71,23 @@ jobs: uses: plugwise/gh-actions/restore-venv@v1 with: cache-key: ${{ needs.cache.outputs.cache-key }} - python-version: ${{ needs.python.outputs.python-version }} + python-version: ${{ needs.cache.outputs.python-version }} venv-dir: ${{ env.VENV }} precommit-home: ${{ env.PRE_COMMIT_HOME }} - 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: @@ -103,24 +104,24 @@ jobs: uses: actions/checkout@v5 - name: Restore cached environment id: cache-reuse - uses: plugwise/ghactions/restore-venv@v1 + uses: plugwise/gh-actions/restore-venv@v1 with: cache-key: ${{ needs.cache.outputs.cache-key }} - python-version: ${{ needs.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 +# . 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: @@ -136,18 +137,23 @@ jobs: steps: - name: Check out committed code uses: actions/checkout@v5 + - name: Set up Python ${{ matrix.python-version }} + id: python + uses: actions/setup-python@v6 + with: + python-version: ${{ matrix.python-version }} - name: Restore cached environment id: cache-reuse - uses: plugwise/ghactions/restore-venv@v1 + uses: plugwise/gh-actions/restore-venv@v1 with: fail-on-miss: false # First time create cache (if not already exists) - cache-key: ${{ needs.cache.outputs.cache-key }}-pytest-matrix-${{ matrix.python-version }} - python-version: ${{ matrix.python-version }} # Force to installed python minor + 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 @@ -172,16 +178,16 @@ jobs: persist-credentials: false - 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: ${{ needs.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 @@ -220,7 +226,7 @@ jobs: uses: plugwise/gh-actions/restore-venv@v1 with: cache-key: ${{ needs.cache.outputs.cache-key }} - python-version: ${{ needs.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 @@ -231,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 "***" @@ -308,11 +314,11 @@ jobs: uses: plugwise/gh-actions/restore-venv@v1 with: cache-key: ${{ needs.cache.outputs.cache-key }} - python-version: ${{ needs.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_usb/ tests/ -s -nc --no-assert diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 997fd2b1b..655c4cc04 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ default_language_version: # force all unspecified python hooks to run python3 - python: python3.14 + python: default repos: # Run manually in CI skipping the branch checks