Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor code quality and performance issues #663

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .deepsource.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version = 1

test_patterns = ["tests/**"]

[[analyzers]]
name = "python"
enabled = true

[analyzers.meta]
runtime_version = "3.x.x"
4 changes: 2 additions & 2 deletions calibre-plugin/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@

try:
from PyQt5 import QtWidgets as QtGui
from PyQt5.Qt import (QWidget, QVBoxLayout, QHBoxLayout, QGridLayout, QLabel,
from PyQt5.Qt import (QVBoxLayout, QHBoxLayout, QGridLayout, QLabel,
QLineEdit, QWidget, QComboBox, QCheckBox, QPushButton, QTabWidget,
QScrollArea, QGroupBox, QButtonGroup, QRadioButton,
Qt)
except ImportError as e:
from PyQt4 import QtGui
from PyQt4.Qt import (QWidget, QVBoxLayout, QHBoxLayout, QGridLayout, QLabel,
from PyQt4.Qt import (QVBoxLayout, QHBoxLayout, QGridLayout, QLabel,
QLineEdit, QWidget, QComboBox, QCheckBox, QPushButton, QTabWidget,
QScrollArea, QGroupBox, QButtonGroup, QRadioButton,
Qt)
Expand Down
1 change: 0 additions & 1 deletion fanficfare/adapters/base_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@

from ..story import Story
from ..requestable import Requestable
from ..htmlcleanup import stripHTML
from ..exceptions import InvalidStoryURL, StoryDoesNotExist, HTTPErrorFFF

# quick convenience class
Expand Down
2 changes: 1 addition & 1 deletion fanficfare/browsercache/basebrowsercache.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def profiled_func(*args, **kwargs):
class BrowserCacheException(Exception):
pass

from ..six import ensure_binary, ensure_text
from ..six import ensure_binary

## difference in seconds between Jan 1 1601 and Jan 1 1970. Chrome
## caches (so far) have kept time stamps as microseconds since
Expand Down
2 changes: 0 additions & 2 deletions fanficfare/configurable.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@
try:
from . import adapters
except ImportError:
import sys
if "fanficfare.adapters" in sys.modules:
adapters = sys.modules["fanficfare.adapters"]
elif "calibre_plugins.fanficfare_plugin.fanficfare.adapters" in sys.modules:
Expand Down Expand Up @@ -286,7 +285,6 @@ def get_valid_set_options():
'fix_pseudo_html': (['webnovel.com'], None, boollist),
'fix_excess_space': (['novelonlinefull.com', 'novelall.com'], ['epub', 'html'], boollist),
'dedup_order_chapter_list': (['wuxiaworld.co', 'novelupdates.cc'], None, boollist),
'show_nsfw_cover_images': (['fiction.live'], None, boollist),
'show_timestamps': (['fiction.live'], None, boollist),
'show_nsfw_cover_images': (['fiction.live'], None, boollist)
}
Expand Down
2 changes: 1 addition & 1 deletion fanficfare/story.py
Original file line number Diff line number Diff line change
Expand Up @@ -1172,7 +1172,7 @@ def get_filename_safe_metadata(self,pattern=None):
pattern = re_compile(self.getConfig("output_filename_safepattern",
r"(^\.|/\.|[^a-zA-Z0-9_\. \[\]\(\)&'-]+)"),
"output_filename_safepattern")
for k in origvalues.keys():
for k in origvalues:
if k == 'formatext': # don't do file extension--we set it anyway.
values[k]=self.getMetadata(k)
else:
Expand Down
2 changes: 1 addition & 1 deletion included_dependencies/cloudscraper/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def __init__(self, *args, **kwargs):

self.allow_brotli = kwargs.pop(
'allow_brotli',
True if 'brotli' in sys.modules.keys() else False
'brotli' in sys.modules.keys()
)

self.user_agent = User_Agent(
Expand Down
2 changes: 1 addition & 1 deletion included_dependencies/html2text/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def name2cp(k):


unifiable_n = {}
for k in config.UNIFIABLE.keys():
for k in config.UNIFIABLE:
unifiable_n[name2cp(k)] = config.UNIFIABLE[k]


Expand Down
4 changes: 2 additions & 2 deletions included_dependencies/html5lib/filters/optionaltags.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def __iter__(self):
yield token

def is_optional_start(self, tagname, previous, next):
type = next and next["type"] or None
type = next["type"] if next else None
if tagname in 'html':
# An html element's start tag may be omitted if the first thing
# inside the html element is not a space character or a comment.
Expand Down Expand Up @@ -86,7 +86,7 @@ def is_optional_start(self, tagname, previous, next):
return False

def is_optional_end(self, tagname, next):
type = next and next["type"] or None
type = next["type"] if next else None
if tagname in ('html', 'head', 'body'):
# An html element's end tag may be omitted if the html element
# is not immediately followed by a space character or a comment.
Expand Down
2 changes: 1 addition & 1 deletion included_dependencies/requests/sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,7 @@ def send(self, request, **kwargs):
if allow_redirects:
# Redirect resolving generator.
gen = self.resolve_redirects(r, request, **kwargs)
history = [resp for resp in gen]
history = list(gen)
else:
history = []

Expand Down
2 changes: 1 addition & 1 deletion included_dependencies/soupsieve/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def filter(select, iterable, namespaces=None, flags=0, **kwargs): # noqa: A001
def comments(tag, limit=0, flags=0, **kwargs):
"""Get comments only."""

return [comment for comment in cm.CommentsMatch(tag).get_comments(limit)]
return list(cm.CommentsMatch(tag).get_comments(limit))


@deprecated("'icomments' is not related to CSS selectors and will be removed in the future.")
Expand Down
2 changes: 1 addition & 1 deletion included_dependencies/soupsieve/css_match.py
Original file line number Diff line number Diff line change
Expand Up @@ -1396,7 +1396,7 @@ def filter(self, iterable): # noqa A001
def comments(self, tag, limit=0):
"""Get comments only."""

return [comment for comment in CommentsMatch(tag).get_comments(limit)]
return list(CommentsMatch(tag).get_comments(limit))

@util.deprecated("'icomments' is not related to CSS selectors and will be removed in the future.")
def icomments(self, tag, limit=0):
Expand Down
2 changes: 1 addition & 1 deletion included_dependencies/urllib3/contrib/securetransport.py
Original file line number Diff line number Diff line change
Expand Up @@ -835,7 +835,7 @@ def verify_mode(self):

@verify_mode.setter
def verify_mode(self, value):
self._verify = True if value == ssl.CERT_REQUIRED else False
self._verify = value == ssl.CERT_REQUIRED

def set_default_verify_paths(self):
# So, this has to do something a bit weird. Specifically, what it does
Expand Down