Skip to content

Commit

Permalink
Update deps used in CI (esp. MyPy and PyLint)
Browse files Browse the repository at this point in the history
  • Loading branch information
aandergr committed Jul 26, 2020
1 parent 612842f commit 2a37116
Show file tree
Hide file tree
Showing 7 changed files with 121 additions and 111 deletions.
2 changes: 1 addition & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ verify_ssl = true
[dev-packages]
pylint = "*"
mypy = "*"
sphinx = "*"
sphinx = "~=2.3"
pyinstaller = "*"
pefile = "*"
pywin32-ctypes = "*"
Expand Down
208 changes: 108 additions & 100 deletions Pipfile.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion deploy/windows/create_exe.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def __main():
f.writelines(lines)

# install dependencies and invoke PyInstaller
commands = ["pip install pipenv==2018.11.26",
commands = ["pip install pipenv==2020.6.2",
"pipenv sync --dev",
"pipenv run pyinstaller --log-level=DEBUG instaloader.spec"]

Expand Down
2 changes: 1 addition & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
requests
sphinx!=1.7.7
sphinx~=2.3
14 changes: 8 additions & 6 deletions instaloader/instaloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from hashlib import md5
from io import BytesIO
from pathlib import Path
from typing import Any, Callable, Iterator, List, Optional, Set, Union
from typing import Any, Callable, ContextManager, IO, Iterator, List, Optional, Set, Union, cast

import requests
import urllib3 # type: ignore
Expand Down Expand Up @@ -351,7 +351,8 @@ def get_filename(index):
except UnicodeEncodeError:
self.context.log('txt', end=' ', flush=True)
with open(filename, 'wb') as text_file:
shutil.copyfileobj(BytesIO(bcaption), text_file)
with BytesIO(bcaption) as bio:
shutil.copyfileobj(cast(IO, bio), text_file)
os.utime(filename, (datetime.now().timestamp(), mtime.timestamp()))

def save_location(self, filename: str, location: PostLocation, mtime: datetime) -> None:
Expand All @@ -361,7 +362,8 @@ def save_location(self, filename: str, location: PostLocation, mtime: datetime)
"https://maps.google.com/maps?q={0},{1}&ll={0},{1}\n".format(location.lat,
location.lng))
with open(filename, 'wb') as text_file:
shutil.copyfileobj(BytesIO(location_string.encode()), text_file)
with BytesIO(location_string.encode()) as bio:
shutil.copyfileobj(cast(IO, bio), text_file)
os.utime(filename, (datetime.now().timestamp(), mtime.timestamp()))
self.context.log('geo', end=' ', flush=True)

Expand Down Expand Up @@ -1106,11 +1108,11 @@ def download_profiles(self, profiles: Set[Profile],
def _error_raiser(_str):
yield

# 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
error_handler = cast(Callable[[Optional[str]], ContextManager[None]],
_error_raiser if raise_errors else self.context.error_catcher)

for profile in profiles:
with error_handler(profile.username): # type: ignore
with error_handler(profile.username):
profile_name = profile.username

# Download profile picture
Expand Down
2 changes: 1 addition & 1 deletion instaloader/instaloadercontext.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def copy_session(session: requests.Session, request_timeout: Optional[float] = N
"""Duplicates a requests.Session."""
new = requests.Session()
new.cookies = requests.utils.cookiejar_from_dict(requests.utils.dict_from_cookiejar(session.cookies))
new.headers = session.headers.copy() # type: ignore
new.headers = session.headers.copy()
if request_timeout is not None:
# Override default timeout behavior.
# Need to silence mypy bug for this. See: https://github.com/python/mypy/issues/2427
Expand Down
2 changes: 1 addition & 1 deletion instaloader/structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

PostComment = namedtuple('PostComment', (*PostCommentAnswer._fields, 'answers')) # type: ignore
for field in PostCommentAnswer._fields:
getattr(PostComment, field).__doc__ = getattr(PostCommentAnswer, field).__doc__
getattr(PostComment, field).__doc__ = getattr(PostCommentAnswer, field).__doc__ # pylint: disable=no-member
PostComment.answers.__doc__ = r"Iterator which yields all :class:`PostCommentAnswer`\ s for the comment." # type: ignore

PostLocation = namedtuple('PostLocation', ['id', 'name', 'slug', 'has_public_page', 'lat', 'lng'])
Expand Down

0 comments on commit 2a37116

Please sign in to comment.