From b745d2c6120e09e693e02ed0c1f1034853baa519 Mon Sep 17 00:00:00 2001 From: Adam Logan Date: Tue, 1 Sep 2026 13:24:49 -0700 Subject: [PATCH 1/2] Fix CI: bump ruff/zuban, remove dead code, drop leaked codecov token Ruff 0.16 promoted CPY001 (copyright notice) to stable under our select=ALL config, breaking CI on every file; ignore it. Bumped pre-commit hook revs to match. Removed a bytes-decode branch in processing.py that static analysis confirms is unreachable given niquests' typed headers.get() return. Dropped the plaintext codecov upload token from codecov.yml (public repo, tokenless upload works). --- .pre-commit-config.yaml | 4 ++-- README.md | 20 +++++++++++--------- codecov.yml | 3 +-- homeassistant_api/processing.py | 4 +--- pyproject.toml | 1 + tests/test_endpoints.py | 1 + 6 files changed, 17 insertions(+), 16 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2e816619..0eea4abd 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -10,9 +10,9 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks hooks: - id: trailing-whitespace - rev: "v4.1.0" + rev: "v6.0.0" - repo: https://github.com/astral-sh/ruff-pre-commit - rev: 'v0.15.6' + rev: 'v0.16.5' hooks: - id: ruff-format - id: ruff-check diff --git a/README.md b/README.md index 926b0c77..8e3c3810 100644 --- a/README.md +++ b/README.md @@ -22,10 +22,10 @@ from homeassistant_api import Client with Client( - '', # i.e. 'http://homeassistant.local:8123/api/' - '' + "", # i.e. 'http://homeassistant.local:8123/api/' + "", ) as client: - client.trigger_service('light', 'turn_on', entity_id="light.living_room") + client.trigger_service("light", "turn_on", entity_id="light.living_room") ``` All four client classes share the same method names. @@ -35,12 +35,14 @@ The async clients (`AsyncClient`, `AsyncWebsocketClient`) use `async def` method import asyncio from homeassistant_api import AsyncClient + async def main(): async with AsyncClient( - '', # i.e. 'http://homeassistant.local:8123/api/' - '', + "", # i.e. 'http://homeassistant.local:8123/api/' + "", ) as client: - await client.trigger_service('light', 'turn_on', entity_id="light.living_room") + await client.trigger_service("light", "turn_on", entity_id="light.living_room") + asyncio.run(main()) ``` @@ -51,10 +53,10 @@ asyncio.run(main()) from homeassistant_api import WebsocketClient with WebsocketClient( - '', # i.e. 'ws://homeassistant.local:8123/api/websocket' - '' + "", # i.e. 'ws://homeassistant.local:8123/api/websocket' + "", ) as ws_client: - ws_client.trigger_service('light', 'turn_on', entity_id="light.living_room") + ws_client.trigger_service("light", "turn_on", entity_id="light.living_room") ``` ## Documentation diff --git a/codecov.yml b/codecov.yml index bada462b..14920021 100644 --- a/codecov.yml +++ b/codecov.yml @@ -1,2 +1 @@ -codecov: - token: 2f0c3d11-6099-4276-a5f0-1ad68499ad26 +codecov: {} diff --git a/homeassistant_api/processing.py b/homeassistant_api/processing.py index 91f6f1f8..1e8cca88 100644 --- a/homeassistant_api/processing.py +++ b/homeassistant_api/processing.py @@ -117,9 +117,7 @@ def _parse_text(response: ResponseType) -> str: def _parse_content(response: ResponseType) -> Any: """Look up and call the appropriate parser by content-type.""" content_type = response.headers.get("content-type", "text/plain") - if isinstance(content_type, bytes): - content_type = content_type.decode("utf-8") # pragma: no cover - mimetype = str(content_type).split(";")[0].strip().lower() + mimetype = content_type.split(";")[0].strip().lower() if (parser := _PARSERS.get(mimetype)) is None: msg = f"No response processor found for mimetype {mimetype!r}." diff --git a/pyproject.toml b/pyproject.toml index e82a7f38..292f9925 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -91,6 +91,7 @@ ignore = [ "FBT", "TD", "FIX", + "CPY", ] [tool.ruff.lint.per-file-ignores] diff --git a/tests/test_endpoints.py b/tests/test_endpoints.py index 43e9e00d..397c7311 100644 --- a/tests/test_endpoints.py +++ b/tests/test_endpoints.py @@ -499,6 +499,7 @@ def test_trigger_service(cached_client: Client) -> None: logger.info(resp) assert isinstance(resp, tuple) + def test_call_service(cached_client: Client) -> None: """Tests the `POST /api/services//` endpoint.""" notify = cached_client.get_domain("notify") From 778eb46c8699cc2ae72e8234f34b3b12585a4dc3 Mon Sep 17 00:00:00 2001 From: Adam Logan Date: Tue, 1 Sep 2026 13:24:54 -0700 Subject: [PATCH 2/2] Bump version to 6.1.0 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 292f9925..6ba90289 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ requires = ["hatchling"] [project] name = "HomeAssistant-API" -version = "6.0.1" +version = "6.1.0" description = "Python Wrapper for Homeassistant's REST API" readme = "README.md" license = "GPL-3.0-or-later"