mirror of https://github.com/home-assistant/core
Add strict typing to Sonarr (#79802)
This commit is contained in:
parent
04f07cecba
commit
5981864992
|
@ -236,6 +236,7 @@ homeassistant.components.skybell.*
|
|||
homeassistant.components.slack.*
|
||||
homeassistant.components.sleepiq.*
|
||||
homeassistant.components.smhi.*
|
||||
homeassistant.components.sonarr.*
|
||||
homeassistant.components.ssdp.*
|
||||
homeassistant.components.statistics.*
|
||||
homeassistant.components.steamist.*
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
"""Base Entity for Sonarr."""
|
||||
from __future__ import annotations
|
||||
|
||||
from aiopyarr import SystemStatus
|
||||
from aiopyarr.models.host_configuration import PyArrHostConfiguration
|
||||
from aiopyarr.sonarr_client import SonarrClient
|
||||
|
@ -31,11 +29,8 @@ class SonarrEntity(Entity):
|
|||
self.system_status = system_status
|
||||
|
||||
@property
|
||||
def device_info(self) -> DeviceInfo | None:
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Return device information about the application."""
|
||||
if self._device_id is None:
|
||||
return None
|
||||
|
||||
return DeviceInfo(
|
||||
identifiers={(DOMAIN, self._device_id)},
|
||||
name="Activity Sensor",
|
||||
|
|
|
@ -5,7 +5,7 @@ from collections.abc import Awaitable, Callable, Coroutine
|
|||
from datetime import timedelta
|
||||
from functools import wraps
|
||||
import logging
|
||||
from typing import Any, TypeVar
|
||||
from typing import Any, TypeVar, cast
|
||||
|
||||
from aiopyarr import ArrConnectionException, ArrException, SystemStatus
|
||||
from aiopyarr.models.host_configuration import PyArrHostConfiguration
|
||||
|
@ -267,7 +267,7 @@ class SonarrSensor(SonarrEntity, SensorEntity):
|
|||
return len(self.data[key])
|
||||
|
||||
if key == "queue" and self.data.get(key) is not None:
|
||||
return self.data[key].totalRecords
|
||||
return cast(int, self.data[key].totalRecords)
|
||||
|
||||
if key == "series" and self.data.get(key) is not None:
|
||||
return len(self.data[key])
|
||||
|
@ -276,6 +276,6 @@ class SonarrSensor(SonarrEntity, SensorEntity):
|
|||
return len(self.data[key])
|
||||
|
||||
if key == "wanted" and self.data.get(key) is not None:
|
||||
return self.data[key].totalRecords
|
||||
return cast(int, self.data[key].totalRecords)
|
||||
|
||||
return None
|
||||
|
|
10
mypy.ini
10
mypy.ini
|
@ -2112,6 +2112,16 @@ disallow_untyped_defs = true
|
|||
warn_return_any = true
|
||||
warn_unreachable = true
|
||||
|
||||
[mypy-homeassistant.components.sonarr.*]
|
||||
check_untyped_defs = true
|
||||
disallow_incomplete_defs = true
|
||||
disallow_subclassing_any = true
|
||||
disallow_untyped_calls = true
|
||||
disallow_untyped_decorators = true
|
||||
disallow_untyped_defs = true
|
||||
warn_return_any = true
|
||||
warn_unreachable = true
|
||||
|
||||
[mypy-homeassistant.components.ssdp.*]
|
||||
check_untyped_defs = true
|
||||
disallow_incomplete_defs = true
|
||||
|
|
Loading…
Reference in New Issue