summaryrefslogtreecommitdiff
path: root/libmat2/torrent.py
diff options
context:
space:
mode:
authorjvoisin2022-08-28 22:29:06 +0200
committerjvoisin2022-08-28 22:29:06 +0200
commitcc5be8608b49d74a633b80a95a49a018d4dcd477 (patch)
tree322c21ba2543831d5a1804ebce50a3f7c2391029 /libmat2/torrent.py
parent292f44c0861a57b54a289641ead7e59f158e307e (diff)
Simplify the typing annotations
Diffstat (limited to 'libmat2/torrent.py')
-rw-r--r--libmat2/torrent.py12
1 files changed, 6 insertions, 6 deletions
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 @@
1import logging 1import logging
2from typing import Union, Tuple, Dict 2from typing import Union
3 3
4from . import abstract 4from . import abstract
5 5
@@ -15,7 +15,7 @@ class TorrentParser(abstract.AbstractParser):
15 if self.dict_repr is None: 15 if self.dict_repr is None:
16 raise ValueError 16 raise ValueError
17 17
18 def get_meta(self) -> Dict[str, Union[str, dict]]: 18 def get_meta(self) -> dict[str, Union[str, dict]]:
19 metadata = {} 19 metadata = {}
20 for key, value in self.dict_repr.items(): 20 for key, value in self.dict_repr.items():
21 if key not in self.allowlist: 21 if key not in self.allowlist:
@@ -56,7 +56,7 @@ class _BencodeHandler:
56 } 56 }
57 57
58 @staticmethod 58 @staticmethod
59 def __decode_int(s: bytes) -> Tuple[int, bytes]: 59 def __decode_int(s: bytes) -> tuple[int, bytes]:
60 s = s[1:] 60 s = s[1:]
61 next_idx = s.index(b'e') 61 next_idx = s.index(b'e')
62 if s.startswith(b'-0'): 62 if s.startswith(b'-0'):
@@ -66,7 +66,7 @@ class _BencodeHandler:
66 return int(s[:next_idx]), s[next_idx+1:] 66 return int(s[:next_idx]), s[next_idx+1:]
67 67
68 @staticmethod 68 @staticmethod
69 def __decode_string(s: bytes) -> Tuple[bytes, bytes]: 69 def __decode_string(s: bytes) -> tuple[bytes, bytes]:
70 colon = s.index(b':') 70 colon = s.index(b':')
71 # FIXME Python3 is broken here, the call to `ord` shouldn't be needed, 71 # FIXME Python3 is broken here, the call to `ord` shouldn't be needed,
72 # but apparently it is. This is utterly idiotic. 72 # but apparently it is. This is utterly idiotic.
@@ -76,7 +76,7 @@ class _BencodeHandler:
76 s = s[1:] 76 s = s[1:]
77 return s[colon:colon+str_len], s[colon+str_len:] 77 return s[colon:colon+str_len], s[colon+str_len:]
78 78
79 def __decode_list(self, s: bytes) -> Tuple[list, bytes]: 79 def __decode_list(self, s: bytes) -> tuple[list, bytes]:
80 ret = list() 80 ret = list()
81 s = s[1:] # skip leading `l` 81 s = s[1:] # skip leading `l`
82 while s[0] != ord('e'): 82 while s[0] != ord('e'):
@@ -84,7 +84,7 @@ class _BencodeHandler:
84 ret.append(value) 84 ret.append(value)
85 return ret, s[1:] 85 return ret, s[1:]
86 86
87 def __decode_dict(self, s: bytes) -> Tuple[dict, bytes]: 87 def __decode_dict(self, s: bytes) -> tuple[dict, bytes]:
88 ret = dict() 88 ret = dict()
89 s = s[1:] # skip leading `d` 89 s = s[1:] # skip leading `d`
90 while s[0] != ord(b'e'): 90 while s[0] != ord(b'e'):