Complete partial annotations
Unfortunately we can't turn on mypy's --disallow-incomplete-defs (yet) due to https://github.com/python/mypy/issues/5954
This commit is contained in:
parent
fda807ce9a
commit
1f36e56e1c
1
mypy.ini
1
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
|
||||
|
@ -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):
|
||||
|
@ -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:
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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:
|
||||
|
@ -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):
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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:
|
||||
|
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user