From 405030771b7f988548f8065ac87fcb526ef3445a Mon Sep 17 00:00:00 2001 From: Eugene Triguba Date: Mon, 9 Feb 2026 20:26:35 -0500 Subject: Fix deprecation warnings from typing module --- lirc/client.py | 16 ++++++++-------- lirc/connection/default_connection.py | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lirc/client.py b/lirc/client.py index 80f514a..b8c7ca0 100644 --- a/lirc/client.py +++ b/lirc/client.py @@ -1,5 +1,5 @@ from pathlib import Path -from typing import List, Type, Union +from typing import Union from .connection.abstract_connection import AbstractConnection from .connection.lircd_connection import LircdConnection @@ -10,7 +10,7 @@ from .reply_packet_parser import ReplyPacketParser class Client: """Communicate with the lircd daemon.""" - def __init__(self, connection: Type[AbstractConnection] = None) -> None: + def __init__(self, connection: Union[type[AbstractConnection], None] = None) -> None: """Initialize the client by connecting to the lircd socket. Args: @@ -34,7 +34,7 @@ class Client: self._connection = connection self._connection.connect() - def _send_command(self, command: str) -> Union[str, List[str]]: + def _send_command(self, command: str) -> Union[str, list[str]]: """Send a command to lircd. Args: @@ -124,7 +124,7 @@ class Client: self._send_command(f"SEND_STOP {remote} {key}") - def list_remotes(self) -> List[str]: + def list_remotes(self) -> list[str]: """List all the remotes that lirc has in its ``/etc/lirc/lircd.conf.d`` folder. @@ -136,7 +136,7 @@ class Client: """ return self._send_command("LIST") - def list_remote_keys(self, remote: str) -> List[str]: + def list_remote_keys(self, remote: str) -> list[str]: """List all the keys for a specific remote. Args: @@ -227,10 +227,10 @@ class Client: LircdCommandFailure: If the command fails. """ self._send_command( - "SIMULATE %016d %02d %s %s\n" % (keycode, repeat_count, key, remote) + f"SIMULATE {keycode:016d} {repeat_count:02d} {key} {remote}\n" ) - def set_transmitters(self, transmitters: Union[int, List[int]]) -> None: + def set_transmitters(self, transmitters: Union[int, list[int]]) -> None: """Set the active transmitters. Example: @@ -247,7 +247,7 @@ class Client: """ mask = transmitters - if isinstance(transmitters, List): + if isinstance(transmitters, list): mask = 0 for transmitter in transmitters: mask |= 1 << (int(transmitter) - 1) diff --git a/lirc/connection/default_connection.py b/lirc/connection/default_connection.py index c44166e..5f8ea43 100644 --- a/lirc/connection/default_connection.py +++ b/lirc/connection/default_connection.py @@ -1,6 +1,6 @@ import platform import socket -from typing import Tuple, Union +from typing import Union from lirc.exceptions import UnsupportedOperatingSystemError @@ -36,7 +36,7 @@ class DefaultConnection: ) @property - def address(self) -> Union[str, Tuple[str, int]]: + def address(self) -> Union[str, tuple[str, int]]: """Retrieves the default address that should be used for lircd on the current operating system. -- cgit v1.2.3