From a5f28c3a2096b6ae086d033188fd5650e0ddfbe6 Mon Sep 17 00:00:00 2001 From: Sergey Matyunin Date: Thu, 3 Sep 2026 00:24:49 +0300 Subject: [PATCH] chore: satisfy custom image backend lint Issue: #51 User-Visible: no --- custom_components/houseplan/decor_assets.py | 3 ++- custom_components/houseplan/http_api.py | 12 ++++++------ custom_components/houseplan/websocket_api.py | 8 +++++++- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/custom_components/houseplan/decor_assets.py b/custom_components/houseplan/decor_assets.py index 6f924239..bac287ac 100644 --- a/custom_components/houseplan/decor_assets.py +++ b/custom_components/houseplan/decor_assets.py @@ -12,10 +12,10 @@ import math import re import struct import xml.etree.ElementTree as ET -from xml.parsers import expat from dataclasses import dataclass from pathlib import Path from typing import Any +from xml.parsers import expat from .const import CONTENT_URL, MAX_DECOR_ASSET_BYTES @@ -328,6 +328,7 @@ def validate_asset( # but truncated/corrupt payloads before they enter the authenticated store. try: from io import BytesIO + from PIL import Image with Image.open(BytesIO(data)) as image: diff --git a/custom_components/houseplan/http_api.py b/custom_components/houseplan/http_api.py index 9a47897c..741c9832 100644 --- a/custom_components/houseplan/http_api.py +++ b/custom_components/houseplan/http_api.py @@ -5,10 +5,10 @@ breaks the connection on a large PDF) but via a plain multipart POST — like me """ from __future__ import annotations +import hashlib +import json import logging import os -import json -import hashlib import shutil import tempfile from datetime import datetime, timezone @@ -17,24 +17,24 @@ from pathlib import Path from aiohttp import web from homeassistant.components.http import HomeAssistantView +from homeassistant.core import HomeAssistant try: # KEY_HASS — the modern way to access hass from the aiohttp application from homeassistant.components.http import KEY_HASS except ImportError: # older HA versions KEY_HASS = "hass" # type: ignore[assignment] -from homeassistant.core import HomeAssistant from .auth import may_write from .const import ( ASSETS_DIR, CONTENT_URL, FILES_DIR, - MAX_EXPORT_BYTES, - MAX_FILES_BYTES, - MAX_FILES_COUNT, MAX_DECOR_ASSET_BYTES, MAX_DECOR_ASSETS_BYTES, MAX_DECOR_ASSETS_COUNT, + MAX_EXPORT_BYTES, + MAX_FILES_BYTES, + MAX_FILES_COUNT, MIN_FREE_BYTES, PLANS_DIR, ) diff --git a/custom_components/houseplan/websocket_api.py b/custom_components/houseplan/websocket_api.py index 4c462f57..b2bdd657 100755 --- a/custom_components/houseplan/websocket_api.py +++ b/custom_components/houseplan/websocket_api.py @@ -45,11 +45,17 @@ from .const import ( SUPPORT_PREVIEW_TTL_S, VERSION, ) -from .decor_assets import ASSET_ID_RE, asset_meta_path, asset_refs, public_asset, read_catalog from .coordinate_canonicalization import ( canonicalize_config_geometry, canonicalize_layout_geometry, ) +from .decor_assets import ( + ASSET_ID_RE, + asset_meta_path, + asset_refs, + public_asset, + read_catalog, +) from .import_export import ( ImportFailure, content_manifest,