mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 12:47:08 +00:00
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.slack.*
|
||||||
homeassistant.components.sleepiq.*
|
homeassistant.components.sleepiq.*
|
||||||
homeassistant.components.smhi.*
|
homeassistant.components.smhi.*
|
||||||
|
homeassistant.components.sonarr.*
|
||||||
homeassistant.components.ssdp.*
|
homeassistant.components.ssdp.*
|
||||||
homeassistant.components.statistics.*
|
homeassistant.components.statistics.*
|
||||||
homeassistant.components.steamist.*
|
homeassistant.components.steamist.*
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
"""Base Entity for Sonarr."""
|
"""Base Entity for Sonarr."""
|
||||||
from __future__ import annotations
|
|
||||||
|
|
||||||
from aiopyarr import SystemStatus
|
from aiopyarr import SystemStatus
|
||||||
from aiopyarr.models.host_configuration import PyArrHostConfiguration
|
from aiopyarr.models.host_configuration import PyArrHostConfiguration
|
||||||
from aiopyarr.sonarr_client import SonarrClient
|
from aiopyarr.sonarr_client import SonarrClient
|
||||||
@ -31,11 +29,8 @@ class SonarrEntity(Entity):
|
|||||||
self.system_status = system_status
|
self.system_status = system_status
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device_info(self) -> DeviceInfo | None:
|
def device_info(self) -> DeviceInfo:
|
||||||
"""Return device information about the application."""
|
"""Return device information about the application."""
|
||||||
if self._device_id is None:
|
|
||||||
return None
|
|
||||||
|
|
||||||
return DeviceInfo(
|
return DeviceInfo(
|
||||||
identifiers={(DOMAIN, self._device_id)},
|
identifiers={(DOMAIN, self._device_id)},
|
||||||
name="Activity Sensor",
|
name="Activity Sensor",
|
||||||
|
@ -5,7 +5,7 @@ from collections.abc import Awaitable, Callable, Coroutine
|
|||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
import logging
|
import logging
|
||||||
from typing import Any, TypeVar
|
from typing import Any, TypeVar, cast
|
||||||
|
|
||||||
from aiopyarr import ArrConnectionException, ArrException, SystemStatus
|
from aiopyarr import ArrConnectionException, ArrException, SystemStatus
|
||||||
from aiopyarr.models.host_configuration import PyArrHostConfiguration
|
from aiopyarr.models.host_configuration import PyArrHostConfiguration
|
||||||
@ -267,7 +267,7 @@ class SonarrSensor(SonarrEntity, SensorEntity):
|
|||||||
return len(self.data[key])
|
return len(self.data[key])
|
||||||
|
|
||||||
if key == "queue" and self.data.get(key) is not None:
|
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:
|
if key == "series" and self.data.get(key) is not None:
|
||||||
return len(self.data[key])
|
return len(self.data[key])
|
||||||
@ -276,6 +276,6 @@ class SonarrSensor(SonarrEntity, SensorEntity):
|
|||||||
return len(self.data[key])
|
return len(self.data[key])
|
||||||
|
|
||||||
if key == "wanted" and self.data.get(key) is not None:
|
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
|
return None
|
||||||
|
10
mypy.ini
10
mypy.ini
@ -2112,6 +2112,16 @@ disallow_untyped_defs = true
|
|||||||
warn_return_any = true
|
warn_return_any = true
|
||||||
warn_unreachable = 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.*]
|
[mypy-homeassistant.components.ssdp.*]
|
||||||
check_untyped_defs = true
|
check_untyped_defs = true
|
||||||
disallow_incomplete_defs = true
|
disallow_incomplete_defs = true
|
||||||
|
Loading…
x
Reference in New Issue
Block a user