From b87cd926e7ef36c55ab9c8e88586d928970a6180 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Wed, 14 Sep 2022 11:13:48 +0200 Subject: [PATCH] Fix image-processing type hint (#78426) --- homeassistant/components/demo/image_processing.py | 5 ++--- homeassistant/components/image_processing/__init__.py | 7 +++---- pylint/plugins/hass_enforce_type_hints.py | 2 +- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/homeassistant/components/demo/image_processing.py b/homeassistant/components/demo/image_processing.py index 5d158db46ab..dc5565a1771 100644 --- a/homeassistant/components/demo/image_processing.py +++ b/homeassistant/components/demo/image_processing.py @@ -1,7 +1,6 @@ """Support for the demo image processing.""" from __future__ import annotations -from homeassistant.components.camera import Image from homeassistant.components.image_processing import ( FaceInformation, ImageProcessingFaceEntity, @@ -49,7 +48,7 @@ class DemoImageProcessingAlpr(ImageProcessingAlprEntity): """Return minimum confidence for send events.""" return 80 - def process_image(self, image: Image) -> None: + def process_image(self, image: bytes) -> None: """Process image.""" demo_data = { "AC3829": 98.3, @@ -81,7 +80,7 @@ class DemoImageProcessingFace(ImageProcessingFaceEntity): """Return minimum confidence for send events.""" return 80 - def process_image(self, image: Image) -> None: + def process_image(self, image: bytes) -> None: """Process image.""" demo_data = [ FaceInformation( diff --git a/homeassistant/components/image_processing/__init__.py b/homeassistant/components/image_processing/__init__.py index de90f7dbf81..26e6d195b92 100644 --- a/homeassistant/components/image_processing/__init__.py +++ b/homeassistant/components/image_processing/__init__.py @@ -123,11 +123,11 @@ class ImageProcessingEntity(Entity): """Return minimum confidence for do some things.""" return None - def process_image(self, image: Image) -> None: + def process_image(self, image: bytes) -> None: """Process image.""" raise NotImplementedError() - async def async_process_image(self, image: Image) -> None: + async def async_process_image(self, image: bytes) -> None: """Process image.""" return await self.hass.async_add_executor_job(self.process_image, image) @@ -137,10 +137,9 @@ class ImageProcessingEntity(Entity): This method is a coroutine. """ camera = self.hass.components.camera - image = None try: - image = await camera.async_get_image( + image: Image = await camera.async_get_image( self.camera_entity, timeout=self.timeout ) diff --git a/pylint/plugins/hass_enforce_type_hints.py b/pylint/plugins/hass_enforce_type_hints.py index 7cd94b3181c..6562785180d 100644 --- a/pylint/plugins/hass_enforce_type_hints.py +++ b/pylint/plugins/hass_enforce_type_hints.py @@ -1366,7 +1366,7 @@ _INHERITANCE_MATCH: dict[str, list[ClassTypeHintMatch]] = { ), TypeHintMatch( function_name="process_image", - arg_types={1: "Image"}, + arg_types={1: "bytes"}, return_type=None, has_async_counterpart=True, ),