Skip to content

Commit dc531dc

Browse files
committed
Switch to use typing.Dict
Python 3.8 annotations needs Dict from typing.Dict (i.e. direct `dict` is not usable). Switch to use it in order to be usable from all Python versions. Related/closes #49 and #71.
1 parent ef3cc13 commit dc531dc

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

transferwee.py

+13-13
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
will be shared via emails or link.
3939
"""
4040

41-
from typing import Any, List, Optional, Union
41+
from typing import Any, Dict, List, Optional, Union
4242
import binascii
4343
import functools
4444
import hashlib
@@ -165,7 +165,7 @@ def download(url: str, file: str = "") -> None:
165165
f.write(chunk)
166166

167167

168-
def _file_name_and_size(file: str) -> dict[str, Union[int, str]]:
168+
def _file_name_and_size(file: str) -> Dict[str, Union[int, str]]:
169169
"""Given a file, prepare the "item_type", "name" and "size" dictionary.
170170
171171
Return a dictionary with "item_type", "name" and "size" keys.
@@ -216,7 +216,7 @@ def _prepare_email_upload(
216216
sender: str,
217217
recipients: List[str],
218218
session: requests.Session,
219-
) -> dict[Any, Any]:
219+
) -> Dict[Any, Any]:
220220
"""Given a list of filenames, message a sender and recipients prepare for
221221
the email upload.
222222
@@ -237,7 +237,7 @@ def _prepare_email_upload(
237237

238238
def _verify_email_upload(
239239
transfer_id: str, session: requests.Session
240-
) -> dict[Any, Any]:
240+
) -> Dict[Any, Any]:
241241
"""Given a transfer_id, read the code from standard input.
242242
243243
Return the parsed JSON response.
@@ -260,7 +260,7 @@ def _prepare_link_upload(
260260
display_name: str,
261261
message: str,
262262
session: requests.Session,
263-
) -> dict[Any, Any]:
263+
) -> Dict[Any, Any]:
264264
"""Given a list of filenames and a message prepare for the link upload.
265265
266266
Return the parsed JSON response.
@@ -278,7 +278,7 @@ def _prepare_link_upload(
278278

279279
def _storm_urls(
280280
authorization: str,
281-
) -> dict[str, str]:
281+
) -> Dict[str, str]:
282282
"""Given an authorization bearer extract storm URLs.
283283
284284
Return a dict with the various storm URLs.
@@ -299,7 +299,7 @@ def _storm_urls(
299299

300300
def _storm_preflight_item(
301301
file: str,
302-
) -> dict[str, Union[List[dict[str, int]], str]]:
302+
) -> Dict[str, Union[List[Dict[str, int]], str]]:
303303
"""Given a file, prepare the item block dictionary.
304304
305305
Return a dictionary with "blocks", "item_type" and "path" keys.
@@ -316,7 +316,7 @@ def _storm_preflight_item(
316316

317317
def _storm_preflight(
318318
authorization: str, filenames: List[str]
319-
) -> dict[Any, Any]:
319+
) -> Dict[Any, Any]:
320320
"""Given an Authorization token and filenames do preflight for upload.
321321
322322
Return the parsed JSON response.
@@ -355,7 +355,7 @@ def _md5(file: str) -> str:
355355
return h.hexdigest()
356356

357357

358-
def _storm_prepare_item(file: str) -> dict[str, Union[int, str]]:
358+
def _storm_prepare_item(file: str) -> Dict[str, Union[int, str]]:
359359
"""Given a file, prepare the block for blocks dictionary.
360360
361361
Return a dictionary with "content_length" and "content_md5_hex" keys.
@@ -365,7 +365,7 @@ def _storm_prepare_item(file: str) -> dict[str, Union[int, str]]:
365365
return {"content_length": filesize, "content_md5_hex": _md5(file)}
366366

367367

368-
def _storm_prepare(authorization: str, filenames: List[str]) -> dict[Any, Any]:
368+
def _storm_prepare(authorization: str, filenames: List[str]) -> Dict[Any, Any]:
369369
"""Given an Authorization token and filenames prepare for block uploads.
370370
371371
Return the parsed JSON response.
@@ -395,7 +395,7 @@ def _storm_prepare(authorization: str, filenames: List[str]) -> dict[Any, Any]:
395395

396396
def _storm_finalize_item(
397397
file: str, block_id: str
398-
) -> dict[str, Union[List[str], str]]:
398+
) -> Dict[str, Union[List[str], str]]:
399399
"""Given a file and block_id prepare the item block dictionary.
400400
401401
Return a dictionary with "block_ids", "item_type" and "path" keys.
@@ -418,7 +418,7 @@ def _storm_finalize_item(
418418

419419
def _storm_finalize(
420420
authorization: str, filenames: List[str], block_ids: List[str]
421-
) -> dict[Any, Any]:
421+
) -> Dict[Any, Any]:
422422
"""Given an Authorization token, filenames and block ids finalize upload.
423423
424424
Return the parsed JSON response.
@@ -494,7 +494,7 @@ def _storm_upload(url: str, file: str) -> None:
494494

495495
def _finalize_upload(
496496
transfer_id: str, session: requests.Session
497-
) -> dict[Any, Any]:
497+
) -> Dict[Any, Any]:
498498
"""Given a transfer_id finalize the upload.
499499
500500
Return the parsed JSON response.

0 commit comments

Comments
 (0)