Fix pep257 issues.
This commit is contained in:
parent
5f454f3440
commit
82322beb03
@ -8,7 +8,7 @@ targets=qutebrowser,scripts
|
||||
# D209: Blank line before closing """ (removed from PEP257)
|
||||
# D402: First line should not be function's signature (false-positives)
|
||||
disable=D102,D209,D402
|
||||
exclude=test_.*
|
||||
exclude=resources.py,test_content_disposition.py
|
||||
|
||||
[pylint]
|
||||
args=--output-format=colorized,--reports=no,--rcfile=.pylintrc
|
||||
|
@ -457,7 +457,9 @@ class Application(QApplication):
|
||||
|
||||
@pyqtSlot()
|
||||
def _handle_signal_wakeup(self):
|
||||
"""This gets called via self._signal_notifier when there's a signal.
|
||||
"""Handle a newly arrived signal.
|
||||
|
||||
This gets called via self._signal_notifier when there's a signal.
|
||||
|
||||
Python will get control here, so the signal will get handled.
|
||||
"""
|
||||
|
@ -59,7 +59,7 @@ class DiskCache(QNetworkDiskCache):
|
||||
return super().cacheSize()
|
||||
|
||||
def fileMetaData(self, filename):
|
||||
"""Returns the QNetworkCacheMetaData for the cache file filename.
|
||||
"""Return the QNetworkCacheMetaData for the cache file filename.
|
||||
|
||||
Args:
|
||||
filename: The file name as a string.
|
||||
@ -137,7 +137,7 @@ class DiskCache(QNetworkDiskCache):
|
||||
return super().remove(url)
|
||||
|
||||
def updateMetaData(self, meta_data):
|
||||
"""Updates the cache meta date for the meta_data's url to meta_data.
|
||||
"""Update the cache meta date for the meta_data's url to meta_data.
|
||||
|
||||
Args:
|
||||
meta_data: A QNetworkCacheMetaData object.
|
||||
@ -148,7 +148,7 @@ class DiskCache(QNetworkDiskCache):
|
||||
super().updateMetaData(meta_data)
|
||||
|
||||
def clear(self):
|
||||
"""Removes all items from the cache."""
|
||||
"""Remove all items from the cache."""
|
||||
if objreg.get('general', 'private-browsing'):
|
||||
return
|
||||
else:
|
||||
|
@ -58,7 +58,7 @@ def _download_dir():
|
||||
|
||||
|
||||
def _path_suggestion(filename):
|
||||
"""Get the suggested file path
|
||||
"""Get the suggested file path.
|
||||
|
||||
Args:
|
||||
filename: The filename to use if included in the suggestion.
|
||||
@ -289,7 +289,7 @@ class DownloadItem(QObject):
|
||||
total=total, errmsg=errmsg))
|
||||
|
||||
def _create_fileobj(self):
|
||||
"""Creates a file object using the internal filename."""
|
||||
"""Create a file object using the internal filename."""
|
||||
try:
|
||||
fileobj = open(self._filename, 'wb')
|
||||
except OSError as e:
|
||||
@ -395,7 +395,7 @@ class DownloadItem(QObject):
|
||||
self.data_changed.emit()
|
||||
|
||||
def delete(self):
|
||||
"""Delete the downloaded file"""
|
||||
"""Delete the downloaded file."""
|
||||
try:
|
||||
if self._filename is not None and os.path.exists(self._filename):
|
||||
os.remove(self._filename)
|
||||
@ -451,7 +451,7 @@ class DownloadItem(QObject):
|
||||
self._create_fileobj()
|
||||
|
||||
def _create_full_filename(self, filename):
|
||||
"""Tries to create the full filename.
|
||||
"""Try to create the full filename.
|
||||
|
||||
Return:
|
||||
True if the full filename was created, False otherwise.
|
||||
@ -785,7 +785,7 @@ class DownloadManager(QAbstractListModel):
|
||||
return download
|
||||
|
||||
def raise_no_download(self, count):
|
||||
"""Raise an exception that the download doesn't exist
|
||||
"""Raise an exception that the download doesn't exist.
|
||||
|
||||
Args:
|
||||
count: The index of the download
|
||||
@ -987,7 +987,7 @@ class DownloadManager(QAbstractListModel):
|
||||
self.endRemoveRows()
|
||||
|
||||
def update_indexes(self):
|
||||
"""Update indexes of all DownloadItems"""
|
||||
"""Update indexes of all DownloadItems."""
|
||||
first_idx = None
|
||||
for i, d in enumerate(self.downloads, 1):
|
||||
if first_idx is None and d.index != i:
|
||||
|
@ -31,9 +31,7 @@ from qutebrowser.utils import qtutils, utils, objreg
|
||||
|
||||
|
||||
def update_geometry(obj):
|
||||
"""WORKAROUND
|
||||
|
||||
This is a horrible workaround for some weird PyQt bug (probably).
|
||||
"""Weird WORKAROUND for some weird PyQt bug (probably).
|
||||
|
||||
This actually should be a method of DownloadView, but for some reason the
|
||||
rowsInserted/rowsRemoved signals don't get disconnected from this method
|
||||
@ -44,7 +42,6 @@ def update_geometry(obj):
|
||||
Original bug: https://github.com/The-Compiler/qutebrowser/issues/167
|
||||
Workaround bug: https://github.com/The-Compiler/qutebrowser/issues/171
|
||||
"""
|
||||
|
||||
def _update_geometry():
|
||||
"""Actually update the geometry if the object still exists."""
|
||||
if sip.isdeleted(obj):
|
||||
|
@ -17,7 +17,7 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with qutebrowser. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
"""Other utilities which don't fit anywhere else. """
|
||||
"""Other utilities which don't fit anywhere else."""
|
||||
|
||||
|
||||
import os.path
|
||||
|
@ -170,7 +170,7 @@ def qute_help(win_id, request):
|
||||
|
||||
|
||||
def qute_settings(win_id, _request):
|
||||
"""Handler for qute:settings. View/change qute configuration"""
|
||||
"""Handler for qute:settings. View/change qute configuration."""
|
||||
html = jinja.env.get_template('settings.html').render(
|
||||
win_id=win_id, title='settings', config=configdata)
|
||||
return html.encode('UTF-8', errors='xmlcharrefreplace')
|
||||
|
@ -17,7 +17,7 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with qutebrowser. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
"""pyPEG parsing for the RFC 6266 (Content-Disposition) header. """
|
||||
"""pyPEG parsing for the RFC 6266 (Content-Disposition) header."""
|
||||
|
||||
import collections
|
||||
import urllib.parse
|
||||
@ -121,6 +121,7 @@ class Language(str):
|
||||
FIXME: This grammar is not 100% correct yet.
|
||||
https://github.com/The-Compiler/qutebrowser/issues/105
|
||||
"""
|
||||
|
||||
grammar = re.compile('[A-Za-z0-9-]+')
|
||||
|
||||
|
||||
@ -234,7 +235,7 @@ class ContentDisposition:
|
||||
"""
|
||||
|
||||
def __init__(self, disposition='inline', assocs=None):
|
||||
"""This constructor is used internally after parsing the header.
|
||||
"""Used internally after parsing the header.
|
||||
|
||||
Instances should generally be created from a factory
|
||||
function, such as parse_headers and its variants.
|
||||
@ -264,7 +265,6 @@ class ContentDisposition:
|
||||
well, due to a certain browser using the part after the dot for
|
||||
mime-sniffing. Saving it to a database is fine by itself though.
|
||||
"""
|
||||
|
||||
if 'filename*' in self.assocs:
|
||||
return self.assocs['filename*']
|
||||
elif 'filename' in self.assocs:
|
||||
|
@ -141,7 +141,6 @@ def serialize(items):
|
||||
If 'data' goes out of scope, reading from 'stream' will result in a
|
||||
segfault!
|
||||
"""
|
||||
|
||||
data = QByteArray()
|
||||
stream = QDataStream(data, QIODevice.ReadWrite)
|
||||
user_data = []
|
||||
|
@ -86,7 +86,6 @@ class ArgumentParser(argparse.ArgumentParser):
|
||||
|
||||
def enum_getter(enum):
|
||||
"""Function factory to get an enum getter."""
|
||||
|
||||
def _get_enum_item(key):
|
||||
"""Helper function to get an enum item.
|
||||
|
||||
@ -104,7 +103,6 @@ def enum_getter(enum):
|
||||
|
||||
def multitype_conv(tpl):
|
||||
"""Function factory to get a type converter for a choice of types."""
|
||||
|
||||
def _convert(value):
|
||||
"""Convert a value according to an iterable of possible arg types."""
|
||||
for typ in set(tpl):
|
||||
|
@ -433,7 +433,6 @@ class Command:
|
||||
Return:
|
||||
An (args, kwargs) tuple.
|
||||
"""
|
||||
|
||||
args = []
|
||||
kwargs = {}
|
||||
signature = inspect.signature(self.handler)
|
||||
|
@ -85,7 +85,6 @@ class change_filter: # pylint: disable=invalid-name
|
||||
Return:
|
||||
The decorated function.
|
||||
"""
|
||||
|
||||
@pyqtSlot(str, str)
|
||||
@functools.wraps(func)
|
||||
def wrapper(wrapper_self, sectname=None, optname=None):
|
||||
|
@ -205,25 +205,26 @@ class IsVisibleIframeTests(unittest.TestCase):
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
"""Set up this base situation
|
||||
0, 0 300, 0
|
||||
##############################
|
||||
# #
|
||||
0,10 # iframe 100,10 #
|
||||
#********** #
|
||||
#*e * elem1: 0, 0 in iframe (visible)
|
||||
#* * #
|
||||
#* e * elem2: 20,90 in iframe (visible)
|
||||
#********** #
|
||||
0,110 #. .100,110 #
|
||||
#. . #
|
||||
#. e . elem3: 20,150 in iframe (not visible)
|
||||
#.......... #
|
||||
# e elem4: 30, 180 in main frame (visible)
|
||||
# #
|
||||
# frame #
|
||||
##############################
|
||||
300, 0 300, 300
|
||||
"""Set up the following base situation.
|
||||
|
||||
0, 0 300, 0
|
||||
##############################
|
||||
# #
|
||||
0,10 # iframe 100,10 #
|
||||
#********** #
|
||||
#*e * elem1: 0, 0 in iframe (visible)
|
||||
#* * #
|
||||
#* e * elem2: 20,90 in iframe (visible)
|
||||
#********** #
|
||||
0,110 #. .100,110 #
|
||||
#. . #
|
||||
#. e . elem3: 20,150 in iframe (not visible)
|
||||
#.......... #
|
||||
# e elem4: 30, 180 in main frame (visible)
|
||||
# #
|
||||
# frame #
|
||||
##############################
|
||||
300, 0 300, 300
|
||||
"""
|
||||
self.frame = stubs.FakeWebFrame(QRect(0, 0, 300, 300))
|
||||
self.iframe = stubs.FakeWebFrame(QRect(0, 10, 100, 100),
|
||||
@ -327,7 +328,7 @@ class GetChildFramesTests(unittest.TestCase):
|
||||
frame.childFrames.assert_called_once_with()
|
||||
|
||||
def test_one_level(self):
|
||||
r"""Test get_child_frames with this tree:
|
||||
r"""Test get_child_frames with one level of children.
|
||||
|
||||
o parent
|
||||
/ \
|
||||
@ -346,7 +347,7 @@ class GetChildFramesTests(unittest.TestCase):
|
||||
child2.childFrames.assert_called_once_with()
|
||||
|
||||
def test_multiple_levels(self):
|
||||
r"""Test get_child_frames with this tree:
|
||||
r"""Test get_child_frames with multiple levels of children.
|
||||
|
||||
o root
|
||||
/ \
|
||||
|
@ -93,25 +93,25 @@ class SearchUrlTests(unittest.TestCase):
|
||||
self.assertEqual(url.query(), 'q=testfoo')
|
||||
|
||||
def test_engine_pre(self):
|
||||
"""Test first word is search engine name"""
|
||||
"""Test search engine name with one word."""
|
||||
url = urlutils._get_search_url('test testfoo')
|
||||
self.assertEqual(url.host(), 'www.qutebrowser.org')
|
||||
self.assertEqual(url.query(), 'q=testfoo')
|
||||
|
||||
def test_engine_pre_multiple_words(self):
|
||||
"""Test first word is search engine name"""
|
||||
"""Test search engine name with multiple words."""
|
||||
url = urlutils._get_search_url('test testfoo bar foo')
|
||||
self.assertEqual(url.host(), 'www.qutebrowser.org')
|
||||
self.assertEqual(url.query(), 'q=testfoo bar foo')
|
||||
|
||||
def test_engine_pre_whitespace_at_end(self):
|
||||
"""Test first word is search engine name"""
|
||||
"""Test search engine name with one word and whitespace."""
|
||||
url = urlutils._get_search_url('test testfoo ')
|
||||
self.assertEqual(url.host(), 'www.qutebrowser.org')
|
||||
self.assertEqual(url.query(), 'q=testfoo')
|
||||
|
||||
def test_engine_with_bang_pre(self):
|
||||
"""Test search engine with a prepended !hasbang."""
|
||||
"""Test search engine with a prepended !bang."""
|
||||
url = urlutils._get_search_url('!python testfoo')
|
||||
self.assertEqual(url.host(), 'www.example.com')
|
||||
self.assertEqual(url.query(), 'q=%21python testfoo')
|
||||
@ -177,13 +177,13 @@ class IsUrlTests(unittest.TestCase):
|
||||
@mock.patch('qutebrowser.utils.urlutils.config', new=stubs.ConfigStub(
|
||||
get_config_stub(True)))
|
||||
def test_search_autosearch(self):
|
||||
"""Test explicit search with auto-search=True"""
|
||||
"""Test explicit search with auto-search=True."""
|
||||
self.assertFalse(urlutils.is_url('test foo'))
|
||||
|
||||
@mock.patch('qutebrowser.utils.urlutils.config', new=stubs.ConfigStub(
|
||||
get_config_stub(False)))
|
||||
def test_search_no_autosearch(self):
|
||||
"""Test explicit search with auto-search=False"""
|
||||
"""Test explicit search with auto-search=False."""
|
||||
self.assertFalse(urlutils.is_url('test foo'))
|
||||
|
||||
|
||||
|
@ -364,7 +364,9 @@ class IsEnumTests(unittest.TestCase):
|
||||
def test_class(self):
|
||||
"""Test is_enum with a non-enum class."""
|
||||
class Test:
|
||||
"""Test class for is_enum"""
|
||||
|
||||
"""Test class for is_enum."""
|
||||
|
||||
pass
|
||||
self.assertFalse(utils.is_enum(Test))
|
||||
|
||||
|
@ -51,7 +51,6 @@ def log_signals(obj):
|
||||
|
||||
Can be used as class decorator.
|
||||
"""
|
||||
|
||||
def log_slot(obj, signal, *args):
|
||||
"""Slot connected to a signal to log it."""
|
||||
dbg = dbg_signal(signal, args)
|
||||
|
@ -17,7 +17,7 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with qutebrowser. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
"""Utilities related to jinja2. """
|
||||
"""Utilities related to jinja2."""
|
||||
|
||||
import os.path
|
||||
|
||||
@ -49,7 +49,7 @@ class Loader(jinja2.BaseLoader):
|
||||
|
||||
|
||||
def _guess_autoescape(template_name):
|
||||
"""Turns autoescape on/off based on the filetype.
|
||||
"""Turn autoescape on/off based on the filetype.
|
||||
|
||||
Based on http://jinja.pocoo.org/docs/dev/api/#autoescaping
|
||||
"""
|
||||
|
@ -88,7 +88,10 @@ def _get_bridge(win_id):
|
||||
|
||||
@pyqtSlot()
|
||||
def on_focus_changed():
|
||||
"""Gets called when a new window has been focused."""
|
||||
"""Show queued messages when a new window has been focused.
|
||||
|
||||
Gets called when a new window has been focused.
|
||||
"""
|
||||
while _QUEUED:
|
||||
msg = _QUEUED.pop()
|
||||
delta = datetime.datetime.now() - msg.time
|
||||
|
@ -193,7 +193,6 @@ def _has_explicit_scheme(url):
|
||||
Args:
|
||||
url: The URL as QUrl.
|
||||
"""
|
||||
|
||||
# Note that generic URI syntax actually would allow a second colon
|
||||
# after the scheme delimiter. Since we don't know of any URIs
|
||||
# using this and want to support e.g. searching for scoped C++
|
||||
|
@ -17,7 +17,7 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with qutebrowser. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
"""Other utilities which don't fit anywhere else. """
|
||||
"""Other utilities which don't fit anywhere else."""
|
||||
|
||||
import io
|
||||
import sys
|
||||
@ -383,11 +383,11 @@ class FakeIOStream(io.TextIOBase):
|
||||
self.write = write_func
|
||||
|
||||
def flush(self):
|
||||
"""This is only here to satisfy pylint."""
|
||||
"""Override flush() to satisfy pylint."""
|
||||
return super().flush()
|
||||
|
||||
def isatty(self):
|
||||
"""This is only here to satisfy pylint."""
|
||||
"""Override isatty() to satisfy pylint."""
|
||||
return super().isatty()
|
||||
|
||||
|
||||
@ -459,7 +459,7 @@ class prevent_exceptions: # pylint: disable=invalid-name
|
||||
self._predicate = predicate
|
||||
|
||||
def __call__(self, func):
|
||||
"""Gets called when a function should be decorated.
|
||||
"""Called when a function should be decorated.
|
||||
|
||||
Args:
|
||||
func: The function to be decorated.
|
||||
|
@ -18,7 +18,7 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with qutebrowser. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
""" Run different codecheckers over a codebase.
|
||||
"""Run different codecheckers over a codebase.
|
||||
|
||||
Runs flake8, pylint, pep257, a CRLF/whitespace/conflict-checker and
|
||||
pyroma/check-manifest by default.
|
||||
|
Loading…
Reference in New Issue
Block a user