From b4078b72db0258887e080bba8b8fb984ec669e1d Mon Sep 17 00:00:00 2001 From: Bas Nijholt Date: Wed, 1 Jan 2025 15:12:08 -0800 Subject: [PATCH] Update .devcontainer --- .devcontainer.json | 8 +++----- scripts/setup-dependencies | 14 +++++++++----- scripts/setup-devcontainer | 10 +++++----- tests/test_config_flow.py | 12 ++++++------ 4 files changed, 23 insertions(+), 21 deletions(-) diff --git a/.devcontainer.json b/.devcontainer.json index 9b9ba58b..66276e69 100644 --- a/.devcontainer.json +++ b/.devcontainer.json @@ -1,7 +1,7 @@ { "name": "basnijholt/adaptive_lighting", - "image": "mcr.microsoft.com/vscode/devcontainers/python:3.12", - "postCreateCommand": "scripts/setup-devcontainer", + "image": "mcr.microsoft.com/devcontainers/python:1-3.13", + "postCreateCommand": "./scripts/setup-devcontainer && source .venv/bin/activate", "forwardPorts": [ 8123 ], @@ -36,7 +36,5 @@ } }, "remoteUser": "vscode", - "features": { - "ghcr.io/devcontainers/features/rust:1": {} - } + "features": {} } diff --git a/scripts/setup-dependencies b/scripts/setup-dependencies index ca14045d..9409ac0c 100755 --- a/scripts/setup-dependencies +++ b/scripts/setup-dependencies @@ -2,7 +2,11 @@ set -ex cd "$(dirname "$0")/.." -pip install -r core/requirements.txt +pip install uv +uv venv +source .venv/bin/activate + +uv pip install -r core/requirements.txt if grep -q 'codecov' core/requirements_test.txt; then # Older HA versions still have `codecov` in `requirements_test.txt` @@ -14,8 +18,8 @@ if grep -q 'mypy-dev==1.10.0a3' core/requirements_test.txt; then # mypy-dev==1.10.0a3 seems to not be available anymore, HA 2024.4 and 2024.5 are affected sed -i 's/mypy-dev==1.10.0a3/mypy-dev==1.10.0b1/' core/requirements_test.txt fi -pip install -r core/requirements_test.txt +uv pip install -r core/requirements_test.txt -pip install -e core/ -pip install ulid-transform # this is in Adaptive-lighting's manifest.json -pip install $(python test_dependencies.py) +uv pip install -e core/ +uv pip install ulid-transform # this is in Adaptive-lighting's manifest.json +uv pip install $(python test_dependencies.py) diff --git a/scripts/setup-devcontainer b/scripts/setup-devcontainer index 11fdd106..bdb82534 100755 --- a/scripts/setup-devcontainer +++ b/scripts/setup-devcontainer @@ -1,5 +1,5 @@ #!/usr/bin/env bash -set -e +set -ex cd "$(dirname "$0")/.." # Clone only if the folder doesn't exist @@ -8,10 +8,10 @@ if [[ ! -d "core" ]]; then fi pip install \ - colorlog==6.7.0 \ - pip>=21.0,<23.2 \ - ruff==0.0.265 + colorlog \ + pip \ + ruff ./scripts/setup-dependencies ./scripts/setup-symlinks -pre-commit install-hooks +uv run pre-commit install-hooks diff --git a/tests/test_config_flow.py b/tests/test_config_flow.py index 7182879d..ef7ae387 100644 --- a/tests/test_config_flow.py +++ b/tests/test_config_flow.py @@ -1,6 +1,5 @@ """Test Adaptive Lighting config flow.""" -from homeassistant import data_entry_flow from homeassistant.components.adaptive_lighting.const import ( CONF_SUNRISE_TIME, CONF_SUNSET_TIME, @@ -11,6 +10,7 @@ from homeassistant.components.adaptive_lighting.const import ( ) from homeassistant.config_entries import SOURCE_IMPORT from homeassistant.const import CONF_NAME +from homeassistant.data_entry_flow import FlowResultType from tests.common import MockConfigEntry @@ -24,7 +24,7 @@ async def test_flow_manual_configuration(hass): context={"source": "user"}, ) - assert result["type"] == data_entry_flow.RESULT_TYPE_FORM + assert result["type"] == FlowResultType.FORM assert result["step_id"] == "user" assert result["handler"] == "adaptive_lighting" @@ -32,7 +32,7 @@ async def test_flow_manual_configuration(hass): result["flow_id"], user_input={CONF_NAME: "living room"}, ) - assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY + assert result["type"] == FlowResultType.CREATE_ENTRY assert result["title"] == "living room" @@ -46,7 +46,7 @@ async def test_import_success(hass): data=data, ) - assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY + assert result["type"] == FlowResultType.CREATE_ENTRY assert result["title"] == DEFAULT_NAME for key, value in data.items(): assert result["data"][key] == value @@ -65,7 +65,7 @@ async def test_options(hass): await hass.config_entries.async_setup(entry.entry_id) result = await hass.config_entries.options.async_init(entry.entry_id) - assert result["type"] == data_entry_flow.RESULT_TYPE_FORM + assert result["type"] == FlowResultType.FORM assert result["step_id"] == "init" data = DEFAULT_DATA.copy() @@ -75,7 +75,7 @@ async def test_options(hass): result["flow_id"], user_input=data, ) - assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY + assert result["type"] == FlowResultType.CREATE_ENTRY for key, value in data.items(): assert result["data"][key] == value