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
4 changed files with 19 additions and 2 deletions

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