From 692cbc000dfc26b2ede8bdd493c884b7df2e6599 Mon Sep 17 00:00:00 2001 From: Alexander Graf Date: Wed, 8 May 2019 21:49:06 +0200 Subject: [PATCH] Use stronger pylint configuration --- .pylintrc | 6 +----- instaloader/__init__.py | 4 ++-- instaloader/instaloader.py | 12 ++++++++---- instaloader/instaloadercontext.py | 3 ++- instaloader/structures.py | 8 ++++++-- 5 files changed, 19 insertions(+), 14 deletions(-) diff --git a/.pylintrc b/.pylintrc index 82df41f..bc1d8ee 100644 --- a/.pylintrc +++ b/.pylintrc @@ -62,9 +62,7 @@ confidence= # --disable=W". disable=invalid-name, missing-docstring, - line-too-long, too-many-lines, - bad-whitespace, print-statement, parameter-unpacking, unpacking-in-except, @@ -83,7 +81,6 @@ disable=invalid-name, useless-suppression, deprecated-pragma, use-symbolic-message-instead, - cyclic-import, too-many-instance-attributes, too-many-public-methods, too-many-branches, @@ -91,7 +88,6 @@ disable=invalid-name, too-many-locals, too-many-statements, no-else-return, - inconsistent-return-statements, no-else-raise, unnecessary-pass, wildcard-import, @@ -362,7 +358,7 @@ indent-after-paren=4 indent-string=' ' # Maximum number of characters on a single line. -max-line-length=100 +max-line-length=120 # Maximum number of lines in a module. max-module-lines=1000 diff --git a/instaloader/__init__.py b/instaloader/__init__.py index 69b85d5..6988169 100644 --- a/instaloader/__init__.py +++ b/instaloader/__init__.py @@ -15,5 +15,5 @@ else: from .exceptions import * from .instaloader import Instaloader from .instaloadercontext import InstaloaderContext -from .structures import (Highlight, Post, PostSidecarNode, PostComment, PostCommentAnswer, PostLocation, Profile, Story, StoryItem, - load_structure_from_file, save_structure_to_file) +from .structures import (Highlight, Post, PostSidecarNode, PostComment, PostCommentAnswer, PostLocation, Profile, Story, + StoryItem, load_structure_from_file, save_structure_to_file) diff --git a/instaloader/instaloader.py b/instaloader/instaloader.py index 6e08ccd..1c9554f 100644 --- a/instaloader/instaloader.py +++ b/instaloader/instaloader.py @@ -21,7 +21,8 @@ import urllib3 # type: ignore from .exceptions import * from .instaloadercontext import InstaloaderContext -from .structures import Highlight, JsonExportable, Post, PostLocation, Profile, Story, StoryItem, save_structure_to_file, load_structure_from_file +from .structures import (Highlight, JsonExportable, Post, PostLocation, Profile, Story, StoryItem, + save_structure_to_file, load_structure_from_file) def get_default_session_filename(username: str) -> str: @@ -369,7 +370,8 @@ class Instaloader: profile_pic_identifier, profile_pic_extension) content_length = profile_pic_response.headers.get('Content-Length', None) if os.path.isfile(filename) and (not self.context.is_logged_in or - content_length is not None and os.path.getsize(filename) >= int(content_length)): + (content_length is not None and + os.path.getsize(filename) >= int(content_length))): self.context.log(filename + ' already exists') return None self.context.write_raw(profile_pic_bytes if profile_pic_bytes else profile_pic_response, filename) @@ -418,7 +420,8 @@ class Instaloader: :raises InvalidArgumentException: If the provided username does not exist. :raises BadCredentialsException: If the provided password is wrong. :raises ConnectionException: If connection to Instagram failed. - :raises TwoFactorAuthRequiredException: First step of 2FA login done, now call :meth:`Instaloader.two_factor_login`.""" + :raises TwoFactorAuthRequiredException: First step of 2FA login done, now call + :meth:`Instaloader.two_factor_login`.""" self.context.login(user, passwd) def two_factor_login(self, two_factor_code) -> None: @@ -641,7 +644,8 @@ class Instaloader: continue self.context.log("[%3i/%3i] " % (count, totalcount), end="", flush=True) count += 1 - with self.context.error_catcher('Download highlights \"{}\" from user {}'.format(user_highlight.title, name)): + with self.context.error_catcher('Download highlights \"{}\" from user {}'.format(user_highlight.title, + name)): downloaded = self.download_storyitem(item, filename_target if filename_target else Path(name) / Path(user_highlight.title)) diff --git a/instaloader/instaloadercontext.py b/instaloader/instaloadercontext.py index 9f8ae54..0d9f069 100644 --- a/instaloader/instaloadercontext.py +++ b/instaloader/instaloadercontext.py @@ -181,7 +181,8 @@ class InstaloaderContext: :raises InvalidArgumentException: If the provided username does not exist. :raises BadCredentialsException: If the provided password is wrong. :raises ConnectionException: If connection to Instagram failed. - :raises TwoFactorAuthRequiredException: First step of 2FA login done, now call :meth:`Instaloader.two_factor_login`.""" + :raises TwoFactorAuthRequiredException: First step of 2FA login done, now call + :meth:`Instaloader.two_factor_login`.""" import http.client # pylint:disable=protected-access http.client._MAXHEADERS = 200 diff --git a/instaloader/structures.py b/instaloader/structures.py index 640020b..72867c1 100644 --- a/instaloader/structures.py +++ b/instaloader/structures.py @@ -190,12 +190,16 @@ class Post: @property def date_local(self) -> datetime: """Timestamp when the post was created (local time zone).""" - return datetime.fromtimestamp(self._node["date"] if "date" in self._node else self._node["taken_at_timestamp"]) + return datetime.fromtimestamp(self._node["date"] + if "date" in self._node + else self._node["taken_at_timestamp"]) @property def date_utc(self) -> datetime: """Timestamp when the post was created (UTC).""" - return datetime.utcfromtimestamp(self._node["date"] if "date" in self._node else self._node["taken_at_timestamp"]) + return datetime.utcfromtimestamp(self._node["date"] + if "date" in self._node + else self._node["taken_at_timestamp"]) @property def date(self) -> datetime: