From 3f9ded3bed7c6aafece48a9ce34322893c6a469e Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Fri, 15 Dec 2017 13:55:06 +0100 Subject: [PATCH] Add missing docstrings --- qutebrowser/browser/browsertab.py | 2 ++ qutebrowser/browser/commands.py | 2 ++ qutebrowser/browser/history.py | 1 + qutebrowser/browser/inspector.py | 1 + qutebrowser/browser/network/pac.py | 1 + qutebrowser/browser/qutescheme.py | 1 + qutebrowser/browser/webengine/webengineelem.py | 1 + qutebrowser/browser/webkit/webkittab.py | 1 + qutebrowser/config/config.py | 2 ++ qutebrowser/keyinput/modeparsers.py | 1 + qutebrowser/mainwindow/tabbedbrowser.py | 1 + qutebrowser/misc/backendproblem.py | 1 + qutebrowser/misc/earlyinit.py | 1 + qutebrowser/utils/debug.py | 1 + qutebrowser/utils/message.py | 1 + qutebrowser/utils/utils.py | 1 + scripts/asciidoc2html.py | 1 + scripts/dev/standardpaths_tester.py | 1 + scripts/dictcli.py | 2 ++ scripts/importer.py | 1 + 20 files changed, 24 insertions(+) diff --git a/qutebrowser/browser/browsertab.py b/qutebrowser/browser/browsertab.py index c8e595baf..57a3f6ba7 100644 --- a/qutebrowser/browser/browsertab.py +++ b/qutebrowser/browser/browsertab.py @@ -487,6 +487,7 @@ class AbstractHistory: raise NotImplementedError def back(self, count=1): + """Go back in the tab's history.""" idx = self.current_idx() - count if idx >= 0: self._go_to_item(self._item_at(idx)) @@ -495,6 +496,7 @@ class AbstractHistory: raise WebTabError("At beginning of history.") def forward(self, count=1): + """Go forward in the tab's history.""" idx = self.current_idx() + count if idx < len(self): self._go_to_item(self._item_at(idx)) diff --git a/qutebrowser/browser/commands.py b/qutebrowser/browser/commands.py index b9df08486..c65df71bc 100644 --- a/qutebrowser/browser/commands.py +++ b/qutebrowser/browser/commands.py @@ -1522,6 +1522,7 @@ class CommandDispatcher: dest = os.path.expanduser(dest) def callback(data): + """Write the data to disk.""" try: with open(dest, 'w', encoding='utf-8') as f: f.write(data) @@ -2040,6 +2041,7 @@ class CommandDispatcher: jseval_cb = None else: def jseval_cb(out): + """Show the data returned from JS.""" if out is None: # Getting the actual error (if any) seems to be difficult. # The error does end up in diff --git a/qutebrowser/browser/history.py b/qutebrowser/browser/history.py index 1901548bf..81d1fb2f9 100644 --- a/qutebrowser/browser/history.py +++ b/qutebrowser/browser/history.py @@ -268,6 +268,7 @@ class WebHistory(sql.SqlTable): return def action(): + """Actually run the import.""" with debug.log_time(log.init, 'Import old history file to sqlite'): try: self._read(path) diff --git a/qutebrowser/browser/inspector.py b/qutebrowser/browser/inspector.py index c88242bb8..9c583f4b3 100644 --- a/qutebrowser/browser/inspector.py +++ b/qutebrowser/browser/inspector.py @@ -94,6 +94,7 @@ class AbstractWebInspector(QWidget): raise NotImplementedError def toggle(self, page): + """Show/hide the inspector.""" if self._widget.isVisible(): self.hide() else: diff --git a/qutebrowser/browser/network/pac.py b/qutebrowser/browser/network/pac.py index 69158fe62..a3f0813c8 100644 --- a/qutebrowser/browser/network/pac.py +++ b/qutebrowser/browser/network/pac.py @@ -59,6 +59,7 @@ def _js_slot(*args): def _decorator(method): @functools.wraps(method) def new_method(self, *args, **kwargs): + """Call the underlying function.""" try: return method(self, *args, **kwargs) except: diff --git a/qutebrowser/browser/qutescheme.py b/qutebrowser/browser/qutescheme.py index 32bc5806a..9cfef039a 100644 --- a/qutebrowser/browser/qutescheme.py +++ b/qutebrowser/browser/qutescheme.py @@ -113,6 +113,7 @@ class add_handler: # noqa: N801,N806 pylint: disable=invalid-name return function def wrapper(self, *args, **kwargs): + """Call the underlying function.""" if self._backend is not None and objects.backend != self._backend: return self.wrong_backend_handler(*args, **kwargs) else: diff --git a/qutebrowser/browser/webengine/webengineelem.py b/qutebrowser/browser/webengine/webengineelem.py index 2df19e6cd..d6d74ebe4 100644 --- a/qutebrowser/browser/webengine/webengineelem.py +++ b/qutebrowser/browser/webengine/webengineelem.py @@ -226,6 +226,7 @@ class WebEngineElement(webelem.AbstractWebElement): QEventLoop.ExcludeUserInputEvents) def reset_setting(_arg): + """Set the JavascriptCanOpenWindows setting to its old value.""" try: view.settings().setAttribute(attribute, could_open_windows) except RuntimeError: diff --git a/qutebrowser/browser/webkit/webkittab.py b/qutebrowser/browser/webkit/webkittab.py index f16beb7fe..6b8f067fd 100644 --- a/qutebrowser/browser/webkit/webkittab.py +++ b/qutebrowser/browser/webkit/webkittab.py @@ -542,6 +542,7 @@ class WebKitElements(browsertab.AbstractElements): def find_id(self, elem_id, callback): def find_id_cb(elems): + """Call the real callback with the found elements.""" if not elems: callback(None) else: diff --git a/qutebrowser/config/config.py b/qutebrowser/config/config.py index 7b9341343..43fb7e839 100644 --- a/qutebrowser/config/config.py +++ b/qutebrowser/config/config.py @@ -104,11 +104,13 @@ class change_filter: # noqa: N801,N806 pylint: disable=invalid-name if self._function: @functools.wraps(func) def wrapper(option=None): + """Call the underlying function.""" if self._check_match(option): return func() else: @functools.wraps(func) def wrapper(wrapper_self, option=None): + """Call the underlying function.""" if self._check_match(option): return func(wrapper_self) diff --git a/qutebrowser/keyinput/modeparsers.py b/qutebrowser/keyinput/modeparsers.py index 40624cee6..1d74e5659 100644 --- a/qutebrowser/keyinput/modeparsers.py +++ b/qutebrowser/keyinput/modeparsers.py @@ -83,6 +83,7 @@ class NormalKeyParser(keyparser.CommandKeyParser): return match def set_inhibited_timeout(self, timeout): + """Ignore keypresses for the given duration.""" if timeout != 0: self._debug_log("Inhibiting the normal mode for {}ms.".format( timeout)) diff --git a/qutebrowser/mainwindow/tabbedbrowser.py b/qutebrowser/mainwindow/tabbedbrowser.py index c78c0eced..c51a7aaff 100644 --- a/qutebrowser/mainwindow/tabbedbrowser.py +++ b/qutebrowser/mainwindow/tabbedbrowser.py @@ -818,6 +818,7 @@ class TabbedBrowser(tabwidget.TabWidget): point, url = self._global_marks[key] def callback(ok): + """Scroll once loading finished.""" if ok: self.cur_load_finished.disconnect(callback) tab.scroller.to_point(point) diff --git a/qutebrowser/misc/backendproblem.py b/qutebrowser/misc/backendproblem.py index 6adc0c722..8a51d50ce 100644 --- a/qutebrowser/misc/backendproblem.py +++ b/qutebrowser/misc/backendproblem.py @@ -364,6 +364,7 @@ def _check_backend_modules(): def init(): + """Check for various issues related to QtWebKit/QtWebEngine.""" _check_backend_modules() if objects.backend == usertypes.Backend.QtWebEngine: _handle_ssl_support() diff --git a/qutebrowser/misc/earlyinit.py b/qutebrowser/misc/earlyinit.py index af53b73a7..9b4a6e8a5 100644 --- a/qutebrowser/misc/earlyinit.py +++ b/qutebrowser/misc/earlyinit.py @@ -261,6 +261,7 @@ def init_log(args): def check_optimize_flag(): + """Check whether qutebrowser is running with -OO.""" from qutebrowser.utils import log if sys.flags.optimize >= 2: log.init.warning("Running on optimize level higher than 1, " diff --git a/qutebrowser/utils/debug.py b/qutebrowser/utils/debug.py index 44699efa1..813b02e7a 100644 --- a/qutebrowser/utils/debug.py +++ b/qutebrowser/utils/debug.py @@ -266,6 +266,7 @@ class log_time: # noqa: N801,N806 pylint: disable=invalid-name def __call__(self, func): @functools.wraps(func) def wrapped(*args, **kwargs): + """Call the original function.""" with self: func(*args, **kwargs) diff --git a/qutebrowser/utils/message.py b/qutebrowser/utils/message.py index 35ab604b0..6957f115d 100644 --- a/qutebrowser/utils/message.py +++ b/qutebrowser/utils/message.py @@ -216,6 +216,7 @@ class GlobalMessageBridge(QObject): self.ask_question.emit(question, blocking) def show(self, level, text, replace=False): + """Show the given message.""" if self._connected: self.show_message.emit(level, text, replace) else: diff --git a/qutebrowser/utils/utils.py b/qutebrowser/utils/utils.py index efd2b2cc8..8333c4132 100644 --- a/qutebrowser/utils/utils.py +++ b/qutebrowser/utils/utils.py @@ -631,6 +631,7 @@ class prevent_exceptions: # noqa: N801,N806 pylint: disable=invalid-name @functools.wraps(func) def wrapper(*args, **kwargs): + """Call the original function.""" try: return func(*args, **kwargs) except BaseException: diff --git a/scripts/asciidoc2html.py b/scripts/asciidoc2html.py index bd51b27ef..dbd4b7679 100755 --- a/scripts/asciidoc2html.py +++ b/scripts/asciidoc2html.py @@ -66,6 +66,7 @@ class AsciiDoc: shutil.rmtree(self._homedir) def build(self): + """Build either the website or the docs.""" if self._args.website: self._build_website() else: diff --git a/scripts/dev/standardpaths_tester.py b/scripts/dev/standardpaths_tester.py index a53b0320a..1cf2fbe4f 100644 --- a/scripts/dev/standardpaths_tester.py +++ b/scripts/dev/standardpaths_tester.py @@ -40,6 +40,7 @@ def print_header(): def print_paths(): + """Print all QStandardPaths.StandardLocation members.""" for name, obj in vars(QStandardPaths).items(): if isinstance(obj, QStandardPaths.StandardLocation): location = QStandardPaths.writableLocation(obj) diff --git a/scripts/dictcli.py b/scripts/dictcli.py index 98754d628..201657a3c 100755 --- a/scripts/dictcli.py +++ b/scripts/dictcli.py @@ -233,6 +233,7 @@ def install(languages): def update(languages): + """Update the given languages.""" installed = [lang for lang in languages if lang.local_version is not None] for lang in installed: if lang.local_version < lang.remote_version: @@ -244,6 +245,7 @@ def update(languages): def remove_old(languages): + """Remove old versions of languages.""" installed = [lang for lang in languages if lang.local_version is not None] for lang in installed: local_files = spell.local_files(lang.code) diff --git a/scripts/importer.py b/scripts/importer.py index 5f22646d6..c97188ffe 100755 --- a/scripts/importer.py +++ b/scripts/importer.py @@ -332,6 +332,7 @@ def import_chrome(profile, bookmark_types, output_format): bookmarks = json.load(f) def bm_tree_walk(bm, template): + """Recursive function to walk through bookmarks.""" assert 'type' in bm, bm if bm['type'] == 'url': if urllib.parse.urlparse(bm['url']).scheme != 'chrome':