Fix import issue with Python 3.5

Closes #293.
This commit is contained in:
Alexander Graf 2019-05-08 21:22:22 +02:00
parent 408cf22c18
commit 33d13c4b32

View File

@ -14,7 +14,7 @@ from functools import wraps
from hashlib import md5 from hashlib import md5
from io import BytesIO from io import BytesIO
from pathlib import Path 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 requests
import urllib3 # type: ignore import urllib3 # type: ignore
@ -952,11 +952,11 @@ class Instaloader:
def _error_raiser(_str): def _error_raiser(_str):
yield yield
error_handler = cast(Callable[[Optional[str]], ContextManager[None]], # error_handler type is Callable[[Optional[str]], ContextManager[None]] (not supported with Python 3.5)
_error_raiser if raise_errors else self.context.error_catcher) error_handler = _error_raiser if raise_errors else self.context.error_catcher
for profile in profiles: for profile in profiles:
with error_handler(profile.username): with error_handler(profile.username): # type: ignore
profile_name = profile.username profile_name = profile.username
# Download profile picture # Download profile picture