From 33d13c4b32858fd7f7ee03791fc025f7e9326122 Mon Sep 17 00:00:00 2001 From: Alexander Graf Date: Wed, 8 May 2019 21:22:22 +0200 Subject: [PATCH] Fix import issue with Python 3.5 Closes #293. --- instaloader/instaloader.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/instaloader/instaloader.py b/instaloader/instaloader.py index 01961b0..6e08ccd 100644 --- a/instaloader/instaloader.py +++ b/instaloader/instaloader.py @@ -14,7 +14,7 @@ from functools import wraps from hashlib import md5 from io import BytesIO from pathlib import Path -from typing import Any, Callable, ContextManager, Iterator, List, Optional, Set, Union, cast +from typing import Any, Callable, Iterator, List, Optional, Set, Union import requests import urllib3 # type: ignore @@ -952,11 +952,11 @@ class Instaloader: def _error_raiser(_str): yield - error_handler = cast(Callable[[Optional[str]], ContextManager[None]], - _error_raiser if raise_errors else self.context.error_catcher) + # error_handler type is Callable[[Optional[str]], ContextManager[None]] (not supported with Python 3.5) + error_handler = _error_raiser if raise_errors else self.context.error_catcher for profile in profiles: - with error_handler(profile.username): + with error_handler(profile.username): # type: ignore profile_name = profile.username # Download profile picture