From 1cf4818640212ad7f980ef7117739e51c0a35fb0 Mon Sep 17 00:00:00 2001 From: Keith Burzinski Date: Fri, 4 Oct 2024 03:07:49 -0500 Subject: [PATCH 1/2] [CI] Use a list when reading idedata for includes (#7535) --- script/clang-tidy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/clang-tidy b/script/clang-tidy index a5da9fd3b0..61199edce3 100755 --- a/script/clang-tidy +++ b/script/clang-tidy @@ -98,7 +98,7 @@ def clang_options(idedata): cmd.extend(["-isystem", directory]) # add library include directories using -isystem to suppress their errors - for directory in set(idedata["includes"]["build"]): + for directory in list(idedata["includes"]["build"]): # skip our own directories, we add those later if ( not directory.startswith(f"{root_path}/") From 0a62106b7bb52dd95d93cf2825edd8065be4821d Mon Sep 17 00:00:00 2001 From: guillempages Date: Sat, 5 Oct 2024 09:07:32 +0200 Subject: [PATCH 2/2] [image] Use "puremagic" instead of "magic" python module (#7536) --- esphome/components/image/__init__.py | 9 ++++----- requirements.txt | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/esphome/components/image/__init__.py b/esphome/components/image/__init__.py index e80ba4498f..c72417bcda 100644 --- a/esphome/components/image/__init__.py +++ b/esphome/components/image/__init__.py @@ -6,7 +6,7 @@ import logging from pathlib import Path import re -from magic import Magic +import puremagic from esphome import core, external_files import esphome.codegen as cg @@ -237,8 +237,8 @@ CONFIG_SCHEMA = cv.All(font.validate_pillow_installed, IMAGE_SCHEMA) def load_svg_image(file: bytes, resize: tuple[int, int]): - # Local import only to allow "validate_pillow_installed" to run *before* importing it - # This import is only needed in case of SVG images; adding it + # Local imports only to allow "validate_pillow_installed" to run *before* importing it + # cairosvg is only needed in case of SVG images; adding it # to the top would force configurations not using SVG to also have it # installed for no reason. from cairosvg import svg2png @@ -281,8 +281,7 @@ async def to_code(config): except Exception as e: raise core.EsphomeError(f"Could not load image file {path}: {e}") - mime = Magic(mime=True) - file_type = mime.from_buffer(file_contents) + file_type = puremagic.from_string(file_contents, mime=True) resize = config.get(CONF_RESIZE) if "svg" in file_type: diff --git a/requirements.txt b/requirements.txt index 3e658de8ad..3ffd364d87 100644 --- a/requirements.txt +++ b/requirements.txt @@ -15,7 +15,7 @@ click==8.1.7 esphome-dashboard==20240620.0 aioesphomeapi==24.6.2 zeroconf==0.132.2 -python-magic==0.4.27 +puremagic==1.27 ruamel.yaml==0.18.6 # dashboard_import # esp-idf requires this, but doesn't bundle it by default