Fix image-processing type hint (#78426)

This commit is contained in:
epenet 2022-09-14 11:13:48 +02:00 committed by GitHub
parent 393f1487a5
commit b87cd926e7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 8 deletions

View file

@ -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(

View file

@ -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
)

View file

@ -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,
),