From a833036b0c354320716617d3e477f2e5e1e47b6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20Elio=20Petten=C3=B2?= Date: Thu, 3 Aug 2023 11:38:27 +0100 Subject: Update typing to PEP 585 style. This replaces the usage of generics from `typing` with built-in or from `collections.abc` since Python 3.9 is the minimum supported version. --- freestyle_hid/_session.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'freestyle_hid/_session.py') diff --git a/freestyle_hid/_session.py b/freestyle_hid/_session.py index 03e8c54..b204284 100644 --- a/freestyle_hid/_session.py +++ b/freestyle_hid/_session.py @@ -6,7 +6,8 @@ import logging import pathlib import random import re -from typing import AnyStr, Callable, Iterator, Optional, Sequence, Tuple +from collections.abc import Iterator, Sequence +from typing import AnyStr, Callable, Optional import construct @@ -57,8 +58,8 @@ _ALWAYS_UNENCRYPTED_MESSAGES = ( def _create_matcher( message_type: int, content: Optional[bytes] -) -> Callable[[Tuple[int, bytes]], bool]: - def _matcher(message: Tuple[int, bytes]) -> bool: +) -> Callable[[tuple[int, bytes]], bool]: + def _matcher(message: tuple[int, bytes]) -> bool: return message[0] == message_type and (content is None or content == message[1]) return _matcher @@ -298,7 +299,7 @@ class Session: self._write_hid(message) - def read_response(self, encrypted: bool = False) -> Tuple[int, bytes]: + def read_response(self, encrypted: bool = False) -> tuple[int, bytes]: """Read the response from the device and extracts it.""" usb_packet = self._handle.read() -- cgit v1.2.3