From 1945748ec9c78b654dd5a11dbe553a1f14d78a7b Mon Sep 17 00:00:00 2001 From: Sander Date: Fri, 9 Feb 2024 15:02:04 +0000 Subject: [PATCH 1/4] Update Python to 3.12 --- .devcontainer/devcontainer.json | 2 +- .github/ISSUE_TEMPLATE/issue.yaml | 2 +- .github/workflows/ci.yaml | 2 +- sonar-project.properties | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index cdb5f7e..15f8825 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,6 +1,6 @@ { "name": "HA KNMI development", - "image": "mcr.microsoft.com/vscode/devcontainers/python:0-3.11-bullseye", + "image": "mcr.microsoft.com/devcontainers/python:3.12-bookworm", "postCreateCommand": "scripts/setup", "forwardPorts": [8123], "customizations": { diff --git a/.github/ISSUE_TEMPLATE/issue.yaml b/.github/ISSUE_TEMPLATE/issue.yaml index 0f2aee2..090f407 100644 --- a/.github/ISSUE_TEMPLATE/issue.yaml +++ b/.github/ISSUE_TEMPLATE/issue.yaml @@ -53,7 +53,7 @@ body: required: true attributes: label: Python version - placeholder: "3.11" + placeholder: "3.12" description: > Can be found in [![System info](https://my.home-assistant.io/badges/system_health.svg)](https://my.home-assistant.io/redirect/system_health/) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 09b0eee..e395bd7 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -7,7 +7,7 @@ on: pull_request: ~ env: - DEFAULT_PYTHON: "3.11" + DEFAULT_PYTHON: "3.12" concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} diff --git a/sonar-project.properties b/sonar-project.properties index 240e9a8..6ef9f5e 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -13,5 +13,5 @@ sonar.sourceEncoding=UTF-8 sonar.sources=custom_components sonar.tests=tests -sonar.python.version=3.11 +sonar.python.version=3.12 sonar.python.coverage.reportPaths=coverage.xml From 8a615d5d65b8edf49c2ddb366d50d477541325a1 Mon Sep 17 00:00:00 2001 From: Sander Date: Fri, 16 Feb 2024 20:57:19 +0000 Subject: [PATCH 2/4] Fix that pytest can run in vscode ui --- .devcontainer/devcontainer.json | 1 + 1 file changed, 1 insertion(+) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 15f8825..c7e91b2 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -22,6 +22,7 @@ "files.eol": "\n", "editor.tabSize": 4, "python.analysis.autoSearchPaths": false, + "python.experiments.optOutFrom": ["pythonTestAdapter"], "python.formatting.blackPath": "/usr/local/py-utils/bin/black", "editor.formatOnPaste": false, "editor.formatOnSave": true, From 8ba9e5ef04ff5972b9814e14f2e9b71051d710bc Mon Sep 17 00:00:00 2001 From: Sander Date: Fri, 16 Feb 2024 20:59:00 +0000 Subject: [PATCH 3/4] Split requirements slightly differently to improve devcontainer setup --- .github/workflows/ci.yaml | 5 ++--- requirements.txt | 5 +---- requirements_dev.txt | 5 +++++ requirements_test.txt | 1 - scripts/setup | 2 +- scripts/update | 7 ++----- 6 files changed, 11 insertions(+), 14 deletions(-) create mode 100644 requirements_dev.txt delete mode 100644 requirements_test.txt diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index d89fe8e..0903c38 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -32,7 +32,7 @@ jobs: - name: Check code formatting with isort uses: isort/isort-action@master with: - requirementsFiles: "requirements.txt requirements_test.txt" + requirementsFiles: "requirements.txt requirements_dev.txt" tests: runs-on: ubuntu-latest @@ -48,8 +48,7 @@ jobs: - name: Install requirements run: | - python3 -m pip install -r requirements.txt - python3 -m pip install -r requirements_test.txt + python3 -m pip install -r requirements_dev.txt - name: Run tests run: | diff --git a/requirements.txt b/requirements.txt index 976bc3a..a55c842 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1 @@ -pip>=21.0,<24.1 -isort -colorlog -homeassistant +homeassistant>=2023.9.0 diff --git a/requirements_dev.txt b/requirements_dev.txt new file mode 100644 index 0000000..19794a5 --- /dev/null +++ b/requirements_dev.txt @@ -0,0 +1,5 @@ +-r requirements.txt +pip>=21.0,<24.1 +isort +colorlog +pytest-homeassistant-custom-component diff --git a/requirements_test.txt b/requirements_test.txt deleted file mode 100644 index 71f5999..0000000 --- a/requirements_test.txt +++ /dev/null @@ -1 +0,0 @@ -pytest-homeassistant-custom-component diff --git a/scripts/setup b/scripts/setup index 141d19f..21695d0 100755 --- a/scripts/setup +++ b/scripts/setup @@ -4,4 +4,4 @@ set -e cd "$(dirname "$0")/.." -python3 -m pip install --requirement requirements.txt +python3 -m pip install --requirement requirements_dev.txt diff --git a/scripts/update b/scripts/update index bb8b892..8f479c6 100755 --- a/scripts/update +++ b/scripts/update @@ -4,9 +4,6 @@ set -e cd "$(dirname "$0")/.." -python3 -m pip install --upgrade --force-reinstall --requirement requirements.txt +sudo apt update && sudo apt -y upgrade -if python -c "import pytest_homeassistant_custom_component" &> /dev/null; then - # User also has test requirements, update those as well. - python3 -m pip install --upgrade --force-reinstall --requirement requirements_test.txt -fi +python3 -m pip install --upgrade --force-reinstall --requirement requirements_dev.txt From f4993be8ecb81ae3fb4d265a1a45f98e02b3a466 Mon Sep 17 00:00:00 2001 From: Sander Date: Fri, 16 Feb 2024 20:59:26 +0000 Subject: [PATCH 4/4] Allow HA to run in Github Codespaces --- .devcontainer/configuration.yaml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.devcontainer/configuration.yaml b/.devcontainer/configuration.yaml index 7ca5553..5c496ee 100644 --- a/.devcontainer/configuration.yaml +++ b/.devcontainer/configuration.yaml @@ -1,9 +1,14 @@ default_config: +http: + use_x_forwarded_for: true + trusted_proxies: + - 127.0.0.1 + - ::1 + logger: default: info logs: custom_components.knmi: debug - # If you need to debug uncommment the line below (doc: https://www.home-assistant.io/integrations/debugpy/) # debugpy: