Add strict typing for transmission (#101904)

This commit is contained in:
Marc Mueller 2023-10-12 22:20:39 +02:00 committed by GitHub
parent 8b134f26a9
commit ff5504f55f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 2 deletions

View File

@ -345,6 +345,7 @@ homeassistant.components.trafikverket_camera.*
homeassistant.components.trafikverket_ferry.*
homeassistant.components.trafikverket_train.*
homeassistant.components.trafikverket_weatherstation.*
homeassistant.components.transmission.*
homeassistant.components.trend.*
homeassistant.components.tts.*
homeassistant.components.twentemilieu.*

View File

@ -1,4 +1,10 @@
"""Constants for the Transmission Bittorent Client component."""
from __future__ import annotations
from collections.abc import Callable
from transmission_rpc import Torrent
DOMAIN = "transmission"
SWITCH_TYPES = {"on_off": "Switch", "turtle_mode": "Turtle mode"}
@ -8,7 +14,7 @@ ORDER_OLDEST_FIRST = "oldest_first"
ORDER_BEST_RATIO_FIRST = "best_ratio_first"
ORDER_WORST_RATIO_FIRST = "worst_ratio_first"
SUPPORTED_ORDER_MODES = {
SUPPORTED_ORDER_MODES: dict[str, Callable[[list[Torrent]], list[Torrent]]] = {
ORDER_NEWEST_FIRST: lambda torrents: sorted(
torrents, key=lambda t: t.date_added, reverse=True
),

View File

@ -163,4 +163,4 @@ class TransmissionDataUpdateCoordinator(DataUpdateCoordinator[SessionStats]):
if self._session is None:
return None
return self._session.alt_speed_enabled
return self._session.alt_speed_enabled # type: ignore[no-any-return]

View File

@ -3212,6 +3212,16 @@ disallow_untyped_defs = true
warn_return_any = true
warn_unreachable = true
[mypy-homeassistant.components.transmission.*]
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.trend.*]
check_untyped_defs = true
disallow_incomplete_defs = true