diff --git a/mypy.ini b/mypy.ini index 797ed0bca..91c314675 100644 --- a/mypy.ini +++ b/mypy.ini @@ -10,6 +10,7 @@ warn_unused_ignores = True disallow_subclassing_any = True # disallow_untyped_calls = True # disallow_untyped_defs = True +# https://github.com/python/mypy/issues/5954 # disallow_incomplete_defs = True # check_untyped_defs = True # disallow_untyped_decorators = True diff --git a/qutebrowser/browser/browsertab.py b/qutebrowser/browser/browsertab.py index 0cd54be7e..02d9b70dd 100644 --- a/qutebrowser/browser/browsertab.py +++ b/qutebrowser/browser/browsertab.py @@ -685,7 +685,7 @@ class AbstractAudio(QObject): self._widget = None self._tab = tab - def set_muted(self, muted: bool, override: bool = False): + def set_muted(self, muted: bool, override: bool = False) -> None: """Set this tab as muted or not. Arguments: @@ -699,7 +699,7 @@ class AbstractAudio(QObject): """Whether this tab is muted.""" raise NotImplementedError - def toggle_muted(self, *, override: bool = False): + def toggle_muted(self, *, override: bool = False) -> None: self.set_muted(not self.is_muted(), override=override) def is_recently_audible(self): diff --git a/qutebrowser/browser/commands.py b/qutebrowser/browser/commands.py index 2af938fb5..5c97aaf53 100644 --- a/qutebrowser/browser/commands.py +++ b/qutebrowser/browser/commands.py @@ -513,7 +513,8 @@ class CommandDispatcher: @cmdutils.register(instance='command-dispatcher', scope='window') @cmdutils.argument('win_id', completion=miscmodels.window) @cmdutils.argument('count', count=True) - def tab_give(self, win_id: int = None, keep=False, count=None): + def tab_give(self, win_id: int = None, keep: bool = False, + count: int = None) -> None: """Give the current tab to a new or existing window if win_id given. If no win_id is given, the tab will get detached into a new window. @@ -601,7 +602,8 @@ class CommandDispatcher: @cmdutils.argument('where', choices=['prev', 'next', 'up', 'increment', 'decrement']) @cmdutils.argument('count', count=True) - def navigate(self, where: str, tab=False, bg=False, window=False, count=1): + def navigate(self, where: str, tab: bool = False, bg: bool = False, + window: bool = False, count: int = 1) -> None: """Open typical prev/next links or navigate using the URL path. This tries to automatically click on typical _Previous Page_ or @@ -665,7 +667,7 @@ class CommandDispatcher: @cmdutils.register(instance='command-dispatcher', scope='window') @cmdutils.argument('count', count=True) - def scroll_px(self, dx: int, dy: int, count=1): + def scroll_px(self, dx: int, dy: int, count: int = 1) -> None: """Scroll the current tab by 'count * dx/dy' pixels. Args: @@ -681,7 +683,7 @@ class CommandDispatcher: @cmdutils.register(instance='command-dispatcher', scope='window') @cmdutils.argument('count', count=True) - def scroll(self, direction: str, count=1): + def scroll(self, direction: str, count: int = 1) -> None: """Scroll the current tab in the given direction. Note you can use `:run-with-count` to have a keybinding with a bigger @@ -719,7 +721,8 @@ class CommandDispatcher: @cmdutils.register(instance='command-dispatcher', scope='window') @cmdutils.argument('count', count=True) @cmdutils.argument('horizontal', flag='x') - def scroll_to_perc(self, perc: float = None, horizontal=False, count=None): + def scroll_to_perc(self, perc: float = None, horizontal: bool = False, + count: int = None) -> None: """Scroll to a specific percentage of the page. The percentage can be given either as argument or as count. @@ -764,7 +767,7 @@ class CommandDispatcher: choices=('next', 'increment')) def scroll_page(self, x: float, y: float, *, top_navigate: str = None, bottom_navigate: str = None, - count=1): + count: int = 1) -> None: """Scroll the frame page-wise. Args: @@ -1120,7 +1123,7 @@ class CommandDispatcher: @cmdutils.argument('index', choices=['last']) @cmdutils.argument('count', count=True) def tab_focus(self, index: typing.Union[str, int] = None, - count=None, no_last=False): + count: int = None, no_last: bool = False) -> None: """Select the tab given as argument/[count]. If neither count nor index are given, it behaves like tab-next. @@ -1161,7 +1164,8 @@ class CommandDispatcher: @cmdutils.register(instance='command-dispatcher', scope='window') @cmdutils.argument('index', choices=['+', '-']) @cmdutils.argument('count', count=True) - def tab_move(self, index: typing.Union[str, int] = None, count=None): + def tab_move(self, index: typing.Union[str, int] = None, + count: int = None) -> None: """Move the current tab according to the argument and [count]. If neither is given, move it to the first position. @@ -1718,10 +1722,10 @@ class CommandDispatcher: @cmdutils.register(instance='command-dispatcher', scope='window') @cmdutils.argument('filter_', choices=['id']) - def click_element(self, filter_: str, value, *, + def click_element(self, filter_: str, value: str, *, target: usertypes.ClickTarget = usertypes.ClickTarget.normal, - force_event=False): + force_event: bool = False) -> None: """Click the element matching the given filter. The given filter needs to result in exactly one element, otherwise, an @@ -2070,8 +2074,8 @@ class CommandDispatcher: @cmdutils.register(instance='command-dispatcher', scope='window', maxsplit=0, no_cmd_split=True) - def jseval(self, js_code, file=False, quiet=False, *, - world: typing.Union[usertypes.JsWorld, int] = None): + def jseval(self, js_code: str, file: bool = False, quiet: bool = False, *, + world: typing.Union[usertypes.JsWorld, int] = None) -> None: """Evaluate a JavaScript string. Args: diff --git a/qutebrowser/browser/downloads.py b/qutebrowser/browser/downloads.py index 9c2a88a87..1709c7425 100644 --- a/qutebrowser/browser/downloads.py +++ b/qutebrowser/browser/downloads.py @@ -1062,7 +1062,7 @@ class DownloadModel(QAbstractListModel): @cmdutils.register(instance='download-model', scope='window', maxsplit=0) @cmdutils.argument('count', count=True) - def download_open(self, cmdline: str = None, count=0): + def download_open(self, cmdline: str = None, count: int = 0) -> None: """Open the last/[count]th download. If no specific command is given, this will use the system's default diff --git a/qutebrowser/browser/webengine/webenginetab.py b/qutebrowser/browser/webengine/webenginetab.py index 0f1d368e9..9945886fa 100644 --- a/qutebrowser/browser/webengine/webenginetab.py +++ b/qutebrowser/browser/webengine/webenginetab.py @@ -670,7 +670,7 @@ class WebEngineAudio(browsertab.AbstractAudio): self._tab.url_changed.connect(self._on_url_changed) config.instance.changed.connect(self._on_config_changed) - def set_muted(self, muted: bool, override: bool = False): + def set_muted(self, muted: bool, override: bool = False) -> None: self._overridden = override page = self._widget.page() page.setAudioMuted(muted) diff --git a/qutebrowser/browser/webengine/webview.py b/qutebrowser/browser/webengine/webview.py index b10cc5f9a..e70226f30 100644 --- a/qutebrowser/browser/webengine/webview.py +++ b/qutebrowser/browser/webengine/webview.py @@ -240,7 +240,7 @@ class WebEnginePage(QWebEnginePage): def acceptNavigationRequest(self, url: QUrl, typ: QWebEnginePage.NavigationType, - is_main_frame: bool): + is_main_frame: bool) -> bool: """Override acceptNavigationRequest to forward it to the tab API.""" type_map = { QWebEnginePage.NavigationTypeLinkClicked: diff --git a/qutebrowser/browser/webkit/webkittab.py b/qutebrowser/browser/webkit/webkittab.py index 2edea1777..c791326ce 100644 --- a/qutebrowser/browser/webkit/webkittab.py +++ b/qutebrowser/browser/webkit/webkittab.py @@ -641,7 +641,7 @@ class WebKitAudio(browsertab.AbstractAudio): """Dummy handling of audio status for QtWebKit.""" - def set_muted(self, muted: bool, override: bool = False): + def set_muted(self, muted: bool, override: bool = False) -> None: raise browsertab.WebTabError('Muting is not supported on QtWebKit!') def is_muted(self): diff --git a/qutebrowser/browser/webkit/webpage.py b/qutebrowser/browser/webkit/webpage.py index ce985b466..0195ec17f 100644 --- a/qutebrowser/browser/webkit/webpage.py +++ b/qutebrowser/browser/webkit/webpage.py @@ -469,7 +469,7 @@ class BrowserPage(QWebPage): def acceptNavigationRequest(self, frame: QWebFrame, request: QNetworkRequest, - typ: QWebPage.NavigationType): + typ: QWebPage.NavigationType) -> bool: """Override acceptNavigationRequest to handle clicked links. Setting linkDelegationPolicy to DelegateAllLinks and using a slot bound diff --git a/qutebrowser/config/configcache.py b/qutebrowser/config/configcache.py index cdba6456a..a421ba85c 100644 --- a/qutebrowser/config/configcache.py +++ b/qutebrowser/config/configcache.py @@ -45,7 +45,7 @@ class ConfigCache: if attr in self._cache: self._cache[attr] = config.instance.get(attr) - def __getitem__(self, attr: str): + def __getitem__(self, attr: str) -> typing.Any: if attr not in self._cache: assert not config.instance.get_opt(attr).supports_pattern self._cache[attr] = config.instance.get(attr) diff --git a/qutebrowser/mainwindow/prompt.py b/qutebrowser/mainwindow/prompt.py index 5eb76c86e..f6a8b1224 100644 --- a/qutebrowser/mainwindow/prompt.py +++ b/qutebrowser/mainwindow/prompt.py @@ -391,7 +391,8 @@ class PromptContainer(QWidget): @cmdutils.register(instance='prompt-container', scope='window', modes=[usertypes.KeyMode.prompt], maxsplit=0) - def prompt_open_download(self, cmdline: str = None, pdfjs=False): + def prompt_open_download(self, cmdline: str = None, + pdfjs: bool = False) -> None: """Immediately open a download. If no specific command is given, this will use the system's default diff --git a/qutebrowser/mainwindow/tabwidget.py b/qutebrowser/mainwindow/tabwidget.py index f9c2ac0e6..a3ba0f1da 100644 --- a/qutebrowser/mainwindow/tabwidget.py +++ b/qutebrowser/mainwindow/tabwidget.py @@ -342,7 +342,7 @@ class TabWidget(QTabWidget): qtutils.ensure_valid(url) return url - def update_tab_favicon(self, tab: QWidget): + def update_tab_favicon(self, tab: QWidget) -> None: """Update favicon of the given tab.""" idx = self.indexOf(tab) @@ -400,7 +400,7 @@ class TabBar(QTabBar): return self.parent().currentWidget() @pyqtSlot(str) - def _on_config_changed(self, option: str): + def _on_config_changed(self, option: str) -> None: if option == 'fonts.tabs': self._set_font() elif option == 'tabs.favicons.scale': @@ -543,7 +543,7 @@ class TabBar(QTabBar): return super().mousePressEvent(e) - def minimumTabSizeHint(self, index, ellipsis: bool = True) -> QSize: + def minimumTabSizeHint(self, index: int, ellipsis: bool = True) -> QSize: """Set the minimum tab size to indicator/icon/... text. Args: @@ -623,7 +623,7 @@ class TabBar(QTabBar): return False return widget.data.pinned - def tabSizeHint(self, index: int): + def tabSizeHint(self, index: int) -> QSize: """Override tabSizeHint to customize qb's tab size. https://wiki.python.org/moin/PyQt/Customising%20tab%20bars diff --git a/qutebrowser/misc/sessions.py b/qutebrowser/misc/sessions.py index 9d3736cdb..b94566830 100644 --- a/qutebrowser/misc/sessions.py +++ b/qutebrowser/misc/sessions.py @@ -511,9 +511,12 @@ class SessionManager(QObject): @cmdutils.argument('win_id', win_id=True) @cmdutils.argument('with_private', flag='p') def session_save(self, name: typing.Union[str, Sentinel] = default, - current=False, quiet=False, force=False, - only_active_window=False, with_private=False, - win_id=None): + current: bool = False, + quiet: bool = False, + force: bool = False, + only_active_window: bool = False, + with_private: bool = False, + win_id: int = None) -> None: """Save a session. Args: diff --git a/qutebrowser/misc/utilcmds.py b/qutebrowser/misc/utilcmds.py index b8d8be447..b893c8d6e 100644 --- a/qutebrowser/misc/utilcmds.py +++ b/qutebrowser/misc/utilcmds.py @@ -44,7 +44,7 @@ from qutebrowser.qt import sip @cmdutils.register(maxsplit=1, no_cmd_split=True, no_replace_variables=True) @cmdutils.argument('win_id', win_id=True) -def later(ms: int, command, win_id): +def later(ms: int, command: str, win_id: int) -> None: """Execute a command after some time. Args: @@ -75,7 +75,7 @@ def later(ms: int, command, win_id): @cmdutils.register(maxsplit=1, no_cmd_split=True, no_replace_variables=True) @cmdutils.argument('win_id', win_id=True) @cmdutils.argument('count', count=True) -def repeat(times: int, command, win_id, count=None): +def repeat(times: int, command: str, win_id: int, count: int = None) -> None: """Repeat a given command. Args: @@ -96,7 +96,8 @@ def repeat(times: int, command, win_id, count=None): @cmdutils.register(maxsplit=1, no_cmd_split=True, no_replace_variables=True) @cmdutils.argument('win_id', win_id=True) @cmdutils.argument('count', count=True) -def run_with_count(count_arg: int, command, win_id, count=1): +def run_with_count(count_arg: int, command: str, win_id: int, + count: int = 1) -> None: """Run a command with the given count. If run_with_count itself is run with a count, it multiplies count_arg. @@ -303,7 +304,7 @@ def repeat_command(win_id, count=None): @cmdutils.register(debug=True, name='debug-log-capacity') -def log_capacity(capacity: int): +def log_capacity(capacity: int) -> None: """Change the number of log lines to be stored in RAM. Args: @@ -320,7 +321,7 @@ def log_capacity(capacity: int): @cmdutils.argument('level', choices=sorted( (level.lower() for level in log.LOG_LEVELS), key=lambda e: log.LOG_LEVELS[e.upper()])) -def debug_log_level(level: str): +def debug_log_level(level: str) -> None: """Change the log level for console logging. Args: @@ -332,7 +333,7 @@ def debug_log_level(level: str): @cmdutils.register(debug=True) -def debug_log_filter(filters: str): +def debug_log_filter(filters: str) -> None: """Change the log filter for console logging. Args: