Fix unifiprotect TypeVar inheritance (#70782)

This commit is contained in:
Marc Mueller 2022-04-26 19:15:47 +02:00 committed by GitHub
parent abdf5bb86a
commit a5fa40180c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 9 additions and 10 deletions

View file

@ -46,7 +46,7 @@ class ProtectRequiredKeysMixin(EntityDescription, Generic[T]):
@dataclass
class ProtectSetableKeysMixin(ProtectRequiredKeysMixin, Generic[T]):
class ProtectSetableKeysMixin(ProtectRequiredKeysMixin[T]):
"""Mixin for settable values."""
ufp_set_method: str | None = None

View file

@ -3,7 +3,6 @@ from __future__ import annotations
from dataclasses import dataclass
from datetime import timedelta
from typing import Generic
from pyunifiprotect.data.devices import Camera, Doorlock, Light
@ -31,7 +30,7 @@ class NumberKeysMixin:
@dataclass
class ProtectNumberEntityDescription(
ProtectSetableKeysMixin, NumberEntityDescription, NumberKeysMixin, Generic[T]
ProtectSetableKeysMixin[T], NumberEntityDescription, NumberKeysMixin
):
"""Describes UniFi Protect Number entity."""

View file

@ -6,7 +6,7 @@ from dataclasses import dataclass
from datetime import timedelta
from enum import Enum
import logging
from typing import Any, Final, Generic
from typing import Any, Final
from pyunifiprotect.api import ProtectApiClient
from pyunifiprotect.data import (
@ -104,7 +104,7 @@ SET_DOORBELL_LCD_MESSAGE_SCHEMA = vol.Schema(
@dataclass
class ProtectSelectEntityDescription(
ProtectSetableKeysMixin, SelectEntityDescription, Generic[T]
ProtectSetableKeysMixin[T], SelectEntityDescription
):
"""Describes UniFi Protect Select entity."""

View file

@ -4,7 +4,7 @@ from __future__ import annotations
from dataclasses import dataclass
from datetime import datetime
import logging
from typing import Any, Generic
from typing import Any
from pyunifiprotect.data import (
NVR,
@ -54,13 +54,13 @@ DEVICE_CLASS_DETECTION = "unifiprotect__detection"
@dataclass
class ProtectSensorEntityDescription(
ProtectRequiredKeysMixin, SensorEntityDescription, Generic[T]
ProtectRequiredKeysMixin[T], SensorEntityDescription
):
"""Describes UniFi Protect Sensor entity."""
precision: int | None = None
def get_ufp_value(self, obj: ProtectDeviceModel) -> Any:
def get_ufp_value(self, obj: T) -> Any:
"""Return value from UniFi Protect device."""
value = super().get_ufp_value(obj)

View file

@ -3,7 +3,7 @@ from __future__ import annotations
from dataclasses import dataclass
import logging
from typing import Any, Generic
from typing import Any
from pyunifiprotect.data import Camera, RecordingMode, VideoMode
from pyunifiprotect.data.base import ProtectAdoptableDeviceModel
@ -24,7 +24,7 @@ _LOGGER = logging.getLogger(__name__)
@dataclass
class ProtectSwitchEntityDescription(
ProtectSetableKeysMixin, SwitchEntityDescription, Generic[T]
ProtectSetableKeysMixin[T], SwitchEntityDescription
):
"""Describes UniFi Protect Switch entity."""