From 54cbc85c13587bedd45c30fd15516b4c355bc47f Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Sun, 13 Aug 2023 18:57:46 +0200 Subject: [PATCH] Add types-Pillow dependency (#98266) --- homeassistant/components/generic/config_flow.py | 4 ++-- homeassistant/util/pil.py | 2 +- requirements_test.txt | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/generic/config_flow.py b/homeassistant/components/generic/config_flow.py index ec94d4c227c..eb2d109caeb 100644 --- a/homeassistant/components/generic/config_flow.py +++ b/homeassistant/components/generic/config_flow.py @@ -12,7 +12,7 @@ from typing import Any from aiohttp import web from async_timeout import timeout from httpx import HTTPStatusError, RequestError, TimeoutException -import PIL +import PIL.Image import voluptuous as vol import yarl @@ -137,7 +137,7 @@ def get_image_type(image: bytes) -> str | None: imagefile = io.BytesIO(image) with contextlib.suppress(PIL.UnidentifiedImageError): img = PIL.Image.open(imagefile) - fmt = img.format.lower() + fmt = img.format.lower() if img.format else None if fmt is None: # if PIL can't figure it out, could be svg. diff --git a/homeassistant/util/pil.py b/homeassistant/util/pil.py index 068b807cbe5..58dd48dec5e 100644 --- a/homeassistant/util/pil.py +++ b/homeassistant/util/pil.py @@ -4,7 +4,7 @@ Can only be used by integrations that have pillow in their requirements. """ from __future__ import annotations -from PIL import ImageDraw +from PIL.ImageDraw import ImageDraw def draw_box( diff --git a/requirements_test.txt b/requirements_test.txt index 76a94c758b9..c1c7fdbdcc3 100644 --- a/requirements_test.txt +++ b/requirements_test.txt @@ -41,6 +41,7 @@ types-decorator==5.1.8.3 types-enum34==1.1.8 types-ipaddress==1.0.8 types-paho-mqtt==1.6.0.6 +types-Pillow==10.0.0.2 types-pkg-resources==0.1.3 types-psutil==5.9.5 types-python-dateutil==2.8.19.13