From cc5be8608b49d74a633b80a95a49a018d4dcd477 Mon Sep 17 00:00:00 2001 From: jvoisin Date: Sun, 28 Aug 2022 22:29:06 +0200 Subject: Simplify the typing annotations --- libmat2/torrent.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'libmat2/torrent.py') diff --git a/libmat2/torrent.py b/libmat2/torrent.py index 1a82740..c547a20 100644 --- a/libmat2/torrent.py +++ b/libmat2/torrent.py @@ -1,5 +1,5 @@ import logging -from typing import Union, Tuple, Dict +from typing import Union from . import abstract @@ -15,7 +15,7 @@ class TorrentParser(abstract.AbstractParser): if self.dict_repr is None: raise ValueError - def get_meta(self) -> Dict[str, Union[str, dict]]: + def get_meta(self) -> dict[str, Union[str, dict]]: metadata = {} for key, value in self.dict_repr.items(): if key not in self.allowlist: @@ -56,7 +56,7 @@ class _BencodeHandler: } @staticmethod - def __decode_int(s: bytes) -> Tuple[int, bytes]: + def __decode_int(s: bytes) -> tuple[int, bytes]: s = s[1:] next_idx = s.index(b'e') if s.startswith(b'-0'): @@ -66,7 +66,7 @@ class _BencodeHandler: return int(s[:next_idx]), s[next_idx+1:] @staticmethod - def __decode_string(s: bytes) -> Tuple[bytes, bytes]: + def __decode_string(s: bytes) -> tuple[bytes, bytes]: colon = s.index(b':') # FIXME Python3 is broken here, the call to `ord` shouldn't be needed, # but apparently it is. This is utterly idiotic. @@ -76,7 +76,7 @@ class _BencodeHandler: s = s[1:] return s[colon:colon+str_len], s[colon+str_len:] - def __decode_list(self, s: bytes) -> Tuple[list, bytes]: + def __decode_list(self, s: bytes) -> tuple[list, bytes]: ret = list() s = s[1:] # skip leading `l` while s[0] != ord('e'): @@ -84,7 +84,7 @@ class _BencodeHandler: ret.append(value) return ret, s[1:] - def __decode_dict(self, s: bytes) -> Tuple[dict, bytes]: + def __decode_dict(self, s: bytes) -> tuple[dict, bytes]: ret = dict() s = s[1:] # skip leading `d` while s[0] != ord(b'e'): -- cgit v1.3