From 67fb3438f3fee2e19ba4926eccf21a604f9c0253 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Sun, 19 Jan 2020 10:06:48 +1000 Subject: [PATCH] add type alias for httpclient callback --- pylib/anki/httpclient.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pylib/anki/httpclient.py b/pylib/anki/httpclient.py index ace66d4df..84bcd04c0 100644 --- a/pylib/anki/httpclient.py +++ b/pylib/anki/httpclient.py @@ -14,17 +14,17 @@ from requests import Response HTTP_BUF_SIZE = 64 * 1024 +ProgressCallback = Callable[[int, int], None] + class AnkiRequestsClient: verify = True timeout = 60 # args are (upload_bytes_in_chunk, download_bytes_in_chunk) - progress_hook: Optional[Callable[[int, int], None]] = None + progress_hook: Optional[ProgressCallback] = None - def __init__( - self, progress_hook: Optional[Callable[[int, int], None]] = None - ) -> None: + def __init__(self, progress_hook: Optional[ProgressCallback] = None) -> None: self.progress_hook = progress_hook self.session = requests.Session() @@ -76,7 +76,7 @@ if os.environ.get("ANKI_NOVERIFYSSL"): class _MonitoringFile(io.BufferedReader): - def __init__(self, raw: io.RawIOBase, hook: Optional[Callable[[int, int], None]]): + def __init__(self, raw: io.RawIOBase, hook: Optional[ProgressCallback]): io.BufferedReader.__init__(self, raw) self.hook = hook