Add and enforce types for api.*/components.*
This commit is contained in:
parent
953042d75d
commit
268ad40982
8
mypy.ini
8
mypy.ini
@ -97,3 +97,11 @@ disallow_incomplete_defs = True
|
|||||||
[mypy-qutebrowser.config.configutils]
|
[mypy-qutebrowser.config.configutils]
|
||||||
disallow_untyped_defs = True
|
disallow_untyped_defs = True
|
||||||
disallow_incomplete_defs = True
|
disallow_incomplete_defs = True
|
||||||
|
|
||||||
|
[mypy-qutebrowser.api.*]
|
||||||
|
disallow_untyped_defs = True
|
||||||
|
disallow_incomplete_defs = True
|
||||||
|
|
||||||
|
[mypy-qutebrowser.components.*]
|
||||||
|
disallow_untyped_defs = True
|
||||||
|
disallow_incomplete_defs = True
|
||||||
|
@ -21,5 +21,6 @@
|
|||||||
|
|
||||||
# pylint: disable=unused-import
|
# pylint: disable=unused-import
|
||||||
from qutebrowser.browser.browsertab import WebTabError, AbstractTab as Tab
|
from qutebrowser.browser.browsertab import WebTabError, AbstractTab as Tab
|
||||||
from qutebrowser.browser.webelem import Error as WebElemError
|
from qutebrowser.browser.webelem import (Error as WebElemError,
|
||||||
|
AbstractWebElement as WebElement)
|
||||||
from qutebrowser.utils.usertypes import ClickTarget, JsWorld
|
from qutebrowser.utils.usertypes import ClickTarget, JsWorld
|
||||||
|
@ -26,7 +26,7 @@ from qutebrowser.api import cmdutils, apitypes
|
|||||||
@cmdutils.register(modes=[cmdutils.KeyMode.caret])
|
@cmdutils.register(modes=[cmdutils.KeyMode.caret])
|
||||||
@cmdutils.argument('tab', value=cmdutils.Value.cur_tab)
|
@cmdutils.argument('tab', value=cmdutils.Value.cur_tab)
|
||||||
@cmdutils.argument('count', value=cmdutils.Value.count)
|
@cmdutils.argument('count', value=cmdutils.Value.count)
|
||||||
def move_to_next_line(tab: apitypes.Tab, count: int = 1):
|
def move_to_next_line(tab: apitypes.Tab, count: int = 1) -> None:
|
||||||
"""Move the cursor or selection to the next line.
|
"""Move the cursor or selection to the next line.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@ -38,7 +38,7 @@ def move_to_next_line(tab: apitypes.Tab, count: int = 1):
|
|||||||
@cmdutils.register(modes=[cmdutils.KeyMode.caret])
|
@cmdutils.register(modes=[cmdutils.KeyMode.caret])
|
||||||
@cmdutils.argument('tab', value=cmdutils.Value.cur_tab)
|
@cmdutils.argument('tab', value=cmdutils.Value.cur_tab)
|
||||||
@cmdutils.argument('count', value=cmdutils.Value.count)
|
@cmdutils.argument('count', value=cmdutils.Value.count)
|
||||||
def move_to_prev_line(tab: apitypes.Tab, count: int = 1):
|
def move_to_prev_line(tab: apitypes.Tab, count: int = 1) -> None:
|
||||||
"""Move the cursor or selection to the prev line.
|
"""Move the cursor or selection to the prev line.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@ -50,7 +50,7 @@ def move_to_prev_line(tab: apitypes.Tab, count: int = 1):
|
|||||||
@cmdutils.register(modes=[cmdutils.KeyMode.caret])
|
@cmdutils.register(modes=[cmdutils.KeyMode.caret])
|
||||||
@cmdutils.argument('tab', value=cmdutils.Value.cur_tab)
|
@cmdutils.argument('tab', value=cmdutils.Value.cur_tab)
|
||||||
@cmdutils.argument('count', value=cmdutils.Value.count)
|
@cmdutils.argument('count', value=cmdutils.Value.count)
|
||||||
def move_to_next_char(tab: apitypes.Tab, count: int = 1):
|
def move_to_next_char(tab: apitypes.Tab, count: int = 1) -> None:
|
||||||
"""Move the cursor or selection to the next char.
|
"""Move the cursor or selection to the next char.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@ -62,7 +62,7 @@ def move_to_next_char(tab: apitypes.Tab, count: int = 1):
|
|||||||
@cmdutils.register(modes=[cmdutils.KeyMode.caret])
|
@cmdutils.register(modes=[cmdutils.KeyMode.caret])
|
||||||
@cmdutils.argument('tab', value=cmdutils.Value.cur_tab)
|
@cmdutils.argument('tab', value=cmdutils.Value.cur_tab)
|
||||||
@cmdutils.argument('count', value=cmdutils.Value.count)
|
@cmdutils.argument('count', value=cmdutils.Value.count)
|
||||||
def move_to_prev_char(tab: apitypes.Tab, count: int = 1):
|
def move_to_prev_char(tab: apitypes.Tab, count: int = 1) -> None:
|
||||||
"""Move the cursor or selection to the previous char.
|
"""Move the cursor or selection to the previous char.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@ -74,7 +74,7 @@ def move_to_prev_char(tab: apitypes.Tab, count: int = 1):
|
|||||||
@cmdutils.register(modes=[cmdutils.KeyMode.caret])
|
@cmdutils.register(modes=[cmdutils.KeyMode.caret])
|
||||||
@cmdutils.argument('tab', value=cmdutils.Value.cur_tab)
|
@cmdutils.argument('tab', value=cmdutils.Value.cur_tab)
|
||||||
@cmdutils.argument('count', value=cmdutils.Value.count)
|
@cmdutils.argument('count', value=cmdutils.Value.count)
|
||||||
def move_to_end_of_word(tab: apitypes.Tab, count: int = 1):
|
def move_to_end_of_word(tab: apitypes.Tab, count: int = 1) -> None:
|
||||||
"""Move the cursor or selection to the end of the word.
|
"""Move the cursor or selection to the end of the word.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@ -86,7 +86,7 @@ def move_to_end_of_word(tab: apitypes.Tab, count: int = 1):
|
|||||||
@cmdutils.register(modes=[cmdutils.KeyMode.caret])
|
@cmdutils.register(modes=[cmdutils.KeyMode.caret])
|
||||||
@cmdutils.argument('tab', value=cmdutils.Value.cur_tab)
|
@cmdutils.argument('tab', value=cmdutils.Value.cur_tab)
|
||||||
@cmdutils.argument('count', value=cmdutils.Value.count)
|
@cmdutils.argument('count', value=cmdutils.Value.count)
|
||||||
def move_to_next_word(tab: apitypes.Tab, count: int = 1):
|
def move_to_next_word(tab: apitypes.Tab, count: int = 1) -> None:
|
||||||
"""Move the cursor or selection to the next word.
|
"""Move the cursor or selection to the next word.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@ -98,7 +98,7 @@ def move_to_next_word(tab: apitypes.Tab, count: int = 1):
|
|||||||
@cmdutils.register(modes=[cmdutils.KeyMode.caret])
|
@cmdutils.register(modes=[cmdutils.KeyMode.caret])
|
||||||
@cmdutils.argument('tab', value=cmdutils.Value.cur_tab)
|
@cmdutils.argument('tab', value=cmdutils.Value.cur_tab)
|
||||||
@cmdutils.argument('count', value=cmdutils.Value.count)
|
@cmdutils.argument('count', value=cmdutils.Value.count)
|
||||||
def move_to_prev_word(tab: apitypes.Tab, count: int = 1):
|
def move_to_prev_word(tab: apitypes.Tab, count: int = 1) -> None:
|
||||||
"""Move the cursor or selection to the previous word.
|
"""Move the cursor or selection to the previous word.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@ -109,14 +109,14 @@ def move_to_prev_word(tab: apitypes.Tab, count: int = 1):
|
|||||||
|
|
||||||
@cmdutils.register(modes=[cmdutils.KeyMode.caret])
|
@cmdutils.register(modes=[cmdutils.KeyMode.caret])
|
||||||
@cmdutils.argument('tab', value=cmdutils.Value.cur_tab)
|
@cmdutils.argument('tab', value=cmdutils.Value.cur_tab)
|
||||||
def move_to_start_of_line(tab: apitypes.Tab):
|
def move_to_start_of_line(tab: apitypes.Tab) -> None:
|
||||||
"""Move the cursor or selection to the start of the line."""
|
"""Move the cursor or selection to the start of the line."""
|
||||||
tab.caret.move_to_start_of_line()
|
tab.caret.move_to_start_of_line()
|
||||||
|
|
||||||
|
|
||||||
@cmdutils.register(modes=[cmdutils.KeyMode.caret])
|
@cmdutils.register(modes=[cmdutils.KeyMode.caret])
|
||||||
@cmdutils.argument('tab', value=cmdutils.Value.cur_tab)
|
@cmdutils.argument('tab', value=cmdutils.Value.cur_tab)
|
||||||
def move_to_end_of_line(tab: apitypes.Tab):
|
def move_to_end_of_line(tab: apitypes.Tab) -> None:
|
||||||
"""Move the cursor or selection to the end of line."""
|
"""Move the cursor or selection to the end of line."""
|
||||||
tab.caret.move_to_end_of_line()
|
tab.caret.move_to_end_of_line()
|
||||||
|
|
||||||
@ -124,7 +124,7 @@ def move_to_end_of_line(tab: apitypes.Tab):
|
|||||||
@cmdutils.register(modes=[cmdutils.KeyMode.caret])
|
@cmdutils.register(modes=[cmdutils.KeyMode.caret])
|
||||||
@cmdutils.argument('tab', value=cmdutils.Value.cur_tab)
|
@cmdutils.argument('tab', value=cmdutils.Value.cur_tab)
|
||||||
@cmdutils.argument('count', value=cmdutils.Value.count)
|
@cmdutils.argument('count', value=cmdutils.Value.count)
|
||||||
def move_to_start_of_next_block(tab: apitypes.Tab, count: int = 1):
|
def move_to_start_of_next_block(tab: apitypes.Tab, count: int = 1) -> None:
|
||||||
"""Move the cursor or selection to the start of next block.
|
"""Move the cursor or selection to the start of next block.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@ -136,7 +136,7 @@ def move_to_start_of_next_block(tab: apitypes.Tab, count: int = 1):
|
|||||||
@cmdutils.register(modes=[cmdutils.KeyMode.caret])
|
@cmdutils.register(modes=[cmdutils.KeyMode.caret])
|
||||||
@cmdutils.argument('tab', value=cmdutils.Value.cur_tab)
|
@cmdutils.argument('tab', value=cmdutils.Value.cur_tab)
|
||||||
@cmdutils.argument('count', value=cmdutils.Value.count)
|
@cmdutils.argument('count', value=cmdutils.Value.count)
|
||||||
def move_to_start_of_prev_block(tab: apitypes.Tab, count: int = 1):
|
def move_to_start_of_prev_block(tab: apitypes.Tab, count: int = 1) -> None:
|
||||||
"""Move the cursor or selection to the start of previous block.
|
"""Move the cursor or selection to the start of previous block.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@ -148,7 +148,7 @@ def move_to_start_of_prev_block(tab: apitypes.Tab, count: int = 1):
|
|||||||
@cmdutils.register(modes=[cmdutils.KeyMode.caret])
|
@cmdutils.register(modes=[cmdutils.KeyMode.caret])
|
||||||
@cmdutils.argument('tab', value=cmdutils.Value.cur_tab)
|
@cmdutils.argument('tab', value=cmdutils.Value.cur_tab)
|
||||||
@cmdutils.argument('count', value=cmdutils.Value.count)
|
@cmdutils.argument('count', value=cmdutils.Value.count)
|
||||||
def move_to_end_of_next_block(tab: apitypes.Tab, count: int = 1):
|
def move_to_end_of_next_block(tab: apitypes.Tab, count: int = 1) -> None:
|
||||||
"""Move the cursor or selection to the end of next block.
|
"""Move the cursor or selection to the end of next block.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@ -160,7 +160,7 @@ def move_to_end_of_next_block(tab: apitypes.Tab, count: int = 1):
|
|||||||
@cmdutils.register(modes=[cmdutils.KeyMode.caret])
|
@cmdutils.register(modes=[cmdutils.KeyMode.caret])
|
||||||
@cmdutils.argument('tab', value=cmdutils.Value.cur_tab)
|
@cmdutils.argument('tab', value=cmdutils.Value.cur_tab)
|
||||||
@cmdutils.argument('count', value=cmdutils.Value.count)
|
@cmdutils.argument('count', value=cmdutils.Value.count)
|
||||||
def move_to_end_of_prev_block(tab: apitypes.Tab, count: int = 1):
|
def move_to_end_of_prev_block(tab: apitypes.Tab, count: int = 1) -> None:
|
||||||
"""Move the cursor or selection to the end of previous block.
|
"""Move the cursor or selection to the end of previous block.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@ -171,35 +171,35 @@ def move_to_end_of_prev_block(tab: apitypes.Tab, count: int = 1):
|
|||||||
|
|
||||||
@cmdutils.register(modes=[cmdutils.KeyMode.caret])
|
@cmdutils.register(modes=[cmdutils.KeyMode.caret])
|
||||||
@cmdutils.argument('tab', value=cmdutils.Value.cur_tab)
|
@cmdutils.argument('tab', value=cmdutils.Value.cur_tab)
|
||||||
def move_to_start_of_document(tab: apitypes.Tab):
|
def move_to_start_of_document(tab: apitypes.Tab) -> None:
|
||||||
"""Move the cursor or selection to the start of the document."""
|
"""Move the cursor or selection to the start of the document."""
|
||||||
tab.caret.move_to_start_of_document()
|
tab.caret.move_to_start_of_document()
|
||||||
|
|
||||||
|
|
||||||
@cmdutils.register(modes=[cmdutils.KeyMode.caret])
|
@cmdutils.register(modes=[cmdutils.KeyMode.caret])
|
||||||
@cmdutils.argument('tab', value=cmdutils.Value.cur_tab)
|
@cmdutils.argument('tab', value=cmdutils.Value.cur_tab)
|
||||||
def move_to_end_of_document(tab: apitypes.Tab):
|
def move_to_end_of_document(tab: apitypes.Tab) -> None:
|
||||||
"""Move the cursor or selection to the end of the document."""
|
"""Move the cursor or selection to the end of the document."""
|
||||||
tab.caret.move_to_end_of_document()
|
tab.caret.move_to_end_of_document()
|
||||||
|
|
||||||
|
|
||||||
@cmdutils.register(modes=[cmdutils.KeyMode.caret])
|
@cmdutils.register(modes=[cmdutils.KeyMode.caret])
|
||||||
@cmdutils.argument('tab', value=cmdutils.Value.cur_tab)
|
@cmdutils.argument('tab', value=cmdutils.Value.cur_tab)
|
||||||
def toggle_selection(tab: apitypes.Tab):
|
def toggle_selection(tab: apitypes.Tab) -> None:
|
||||||
"""Toggle caret selection mode."""
|
"""Toggle caret selection mode."""
|
||||||
tab.caret.toggle_selection()
|
tab.caret.toggle_selection()
|
||||||
|
|
||||||
|
|
||||||
@cmdutils.register(modes=[cmdutils.KeyMode.caret])
|
@cmdutils.register(modes=[cmdutils.KeyMode.caret])
|
||||||
@cmdutils.argument('tab', value=cmdutils.Value.cur_tab)
|
@cmdutils.argument('tab', value=cmdutils.Value.cur_tab)
|
||||||
def drop_selection(tab: apitypes.Tab):
|
def drop_selection(tab: apitypes.Tab) -> None:
|
||||||
"""Drop selection and keep selection mode enabled."""
|
"""Drop selection and keep selection mode enabled."""
|
||||||
tab.caret.drop_selection()
|
tab.caret.drop_selection()
|
||||||
|
|
||||||
|
|
||||||
@cmdutils.register()
|
@cmdutils.register()
|
||||||
@cmdutils.argument('tab_obj', value=cmdutils.Value.cur_tab)
|
@cmdutils.argument('tab_obj', value=cmdutils.Value.cur_tab)
|
||||||
def follow_selected(tab_obj: apitypes.Tab, *, tab=False):
|
def follow_selected(tab_obj: apitypes.Tab, *, tab: bool = False) -> None:
|
||||||
"""Follow the selected text.
|
"""Follow the selected text.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -37,7 +37,7 @@ from qutebrowser.api import cmdutils, apitypes, message, config
|
|||||||
|
|
||||||
@cmdutils.register(name='reload')
|
@cmdutils.register(name='reload')
|
||||||
@cmdutils.argument('tab', value=cmdutils.Value.count_tab)
|
@cmdutils.argument('tab', value=cmdutils.Value.count_tab)
|
||||||
def reloadpage(tab, force=False):
|
def reloadpage(tab: apitypes.Tab, force: bool = False) -> None:
|
||||||
"""Reload the current/[count]th tab.
|
"""Reload the current/[count]th tab.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@ -50,7 +50,7 @@ def reloadpage(tab, force=False):
|
|||||||
|
|
||||||
@cmdutils.register()
|
@cmdutils.register()
|
||||||
@cmdutils.argument('tab', value=cmdutils.Value.count_tab)
|
@cmdutils.argument('tab', value=cmdutils.Value.count_tab)
|
||||||
def stop(tab):
|
def stop(tab: apitypes.Tab) -> None:
|
||||||
"""Stop loading in the current/[count]th tab.
|
"""Stop loading in the current/[count]th tab.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@ -60,9 +60,9 @@ def stop(tab):
|
|||||||
tab.stop()
|
tab.stop()
|
||||||
|
|
||||||
|
|
||||||
def _print_preview(tab):
|
def _print_preview(tab: apitypes.Tab) -> None:
|
||||||
"""Show a print preview."""
|
"""Show a print preview."""
|
||||||
def print_callback(ok):
|
def print_callback(ok: bool) -> None:
|
||||||
if not ok:
|
if not ok:
|
||||||
message.error("Printing failed!")
|
message.error("Printing failed!")
|
||||||
|
|
||||||
@ -76,7 +76,7 @@ def _print_preview(tab):
|
|||||||
diag.exec_()
|
diag.exec_()
|
||||||
|
|
||||||
|
|
||||||
def _print_pdf(tab, filename):
|
def _print_pdf(tab: apitypes.Tab, filename: str) -> None:
|
||||||
"""Print to the given PDF file."""
|
"""Print to the given PDF file."""
|
||||||
tab.printing.check_pdf_support()
|
tab.printing.check_pdf_support()
|
||||||
filename = os.path.expanduser(filename)
|
filename = os.path.expanduser(filename)
|
||||||
@ -90,7 +90,9 @@ def _print_pdf(tab, filename):
|
|||||||
@cmdutils.register(name='print')
|
@cmdutils.register(name='print')
|
||||||
@cmdutils.argument('tab', value=cmdutils.Value.count_tab)
|
@cmdutils.argument('tab', value=cmdutils.Value.count_tab)
|
||||||
@cmdutils.argument('pdf', flag='f', metavar='file')
|
@cmdutils.argument('pdf', flag='f', metavar='file')
|
||||||
def printpage(tab, preview=False, *, pdf=None):
|
def printpage(tab: apitypes.Tab,
|
||||||
|
preview: bool = False, *,
|
||||||
|
pdf: str = None) -> None:
|
||||||
"""Print the current/[count]th tab.
|
"""Print the current/[count]th tab.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@ -114,7 +116,7 @@ def printpage(tab, preview=False, *, pdf=None):
|
|||||||
|
|
||||||
@cmdutils.register()
|
@cmdutils.register()
|
||||||
@cmdutils.argument('tab', value=cmdutils.Value.cur_tab)
|
@cmdutils.argument('tab', value=cmdutils.Value.cur_tab)
|
||||||
def home(tab):
|
def home(tab: apitypes.Tab) -> None:
|
||||||
"""Open main startpage in current tab."""
|
"""Open main startpage in current tab."""
|
||||||
if tab.data.pinned:
|
if tab.data.pinned:
|
||||||
message.info("Tab is pinned!")
|
message.info("Tab is pinned!")
|
||||||
@ -124,7 +126,7 @@ def home(tab):
|
|||||||
|
|
||||||
@cmdutils.register(debug=True)
|
@cmdutils.register(debug=True)
|
||||||
@cmdutils.argument('tab', value=cmdutils.Value.cur_tab)
|
@cmdutils.argument('tab', value=cmdutils.Value.cur_tab)
|
||||||
def debug_dump_page(tab, dest, plain=False):
|
def debug_dump_page(tab: apitypes.Tab, dest: str, plain: bool = False) -> None:
|
||||||
"""Dump the current page's content to a file.
|
"""Dump the current page's content to a file.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@ -133,7 +135,7 @@ def debug_dump_page(tab, dest, plain=False):
|
|||||||
"""
|
"""
|
||||||
dest = os.path.expanduser(dest)
|
dest = os.path.expanduser(dest)
|
||||||
|
|
||||||
def callback(data):
|
def callback(data: str) -> None:
|
||||||
"""Write the data to disk."""
|
"""Write the data to disk."""
|
||||||
try:
|
try:
|
||||||
with open(dest, 'w', encoding='utf-8') as f:
|
with open(dest, 'w', encoding='utf-8') as f:
|
||||||
@ -148,13 +150,13 @@ def debug_dump_page(tab, dest, plain=False):
|
|||||||
|
|
||||||
@cmdutils.register(maxsplit=0)
|
@cmdutils.register(maxsplit=0)
|
||||||
@cmdutils.argument('tab', value=cmdutils.Value.cur_tab)
|
@cmdutils.argument('tab', value=cmdutils.Value.cur_tab)
|
||||||
def insert_text(tab, text):
|
def insert_text(tab: apitypes.Tab, text: str) -> None:
|
||||||
"""Insert text at cursor position.
|
"""Insert text at cursor position.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
text: The text to insert.
|
text: The text to insert.
|
||||||
"""
|
"""
|
||||||
def _insert_text_cb(elem):
|
def _insert_text_cb(elem: apitypes.WebElement) -> None:
|
||||||
if elem is None:
|
if elem is None:
|
||||||
message.error("No element focused!")
|
message.error("No element focused!")
|
||||||
return
|
return
|
||||||
@ -170,7 +172,7 @@ def insert_text(tab, text):
|
|||||||
@cmdutils.register()
|
@cmdutils.register()
|
||||||
@cmdutils.argument('tab', value=cmdutils.Value.cur_tab)
|
@cmdutils.argument('tab', value=cmdutils.Value.cur_tab)
|
||||||
@cmdutils.argument('filter_', choices=['id'])
|
@cmdutils.argument('filter_', choices=['id'])
|
||||||
def click_element(tab, filter_: str, value: str, *,
|
def click_element(tab: apitypes.Tab, filter_: str, value: str, *,
|
||||||
target: apitypes.ClickTarget =
|
target: apitypes.ClickTarget =
|
||||||
apitypes.ClickTarget.normal,
|
apitypes.ClickTarget.normal,
|
||||||
force_event: bool = False) -> None:
|
force_event: bool = False) -> None:
|
||||||
@ -186,7 +188,7 @@ def click_element(tab, filter_: str, value: str, *,
|
|||||||
target: How to open the clicked element (normal/tab/tab-bg/window).
|
target: How to open the clicked element (normal/tab/tab-bg/window).
|
||||||
force_event: Force generating a fake click event.
|
force_event: Force generating a fake click event.
|
||||||
"""
|
"""
|
||||||
def single_cb(elem):
|
def single_cb(elem: apitypes.WebElement) -> None:
|
||||||
"""Click a single element."""
|
"""Click a single element."""
|
||||||
if elem is None:
|
if elem is None:
|
||||||
message.error("No element found with id {}!".format(value))
|
message.error("No element found with id {}!".format(value))
|
||||||
@ -207,7 +209,7 @@ def click_element(tab, filter_: str, value: str, *,
|
|||||||
@cmdutils.register(debug=True)
|
@cmdutils.register(debug=True)
|
||||||
@cmdutils.argument('tab', value=cmdutils.Value.cur_tab)
|
@cmdutils.argument('tab', value=cmdutils.Value.cur_tab)
|
||||||
@cmdutils.argument('count', value=cmdutils.Value.count)
|
@cmdutils.argument('count', value=cmdutils.Value.count)
|
||||||
def debug_webaction(tab, action, count=1):
|
def debug_webaction(tab: apitypes.Tab, action: str, count: int = 1) -> None:
|
||||||
"""Execute a webaction.
|
"""Execute a webaction.
|
||||||
|
|
||||||
Available actions:
|
Available actions:
|
||||||
@ -227,7 +229,7 @@ def debug_webaction(tab, action, count=1):
|
|||||||
|
|
||||||
@cmdutils.register()
|
@cmdutils.register()
|
||||||
@cmdutils.argument('tab', value=cmdutils.Value.count_tab)
|
@cmdutils.argument('tab', value=cmdutils.Value.count_tab)
|
||||||
def tab_mute(tab):
|
def tab_mute(tab: apitypes.Tab) -> None:
|
||||||
"""Mute/Unmute the current/[count]th tab.
|
"""Mute/Unmute the current/[count]th tab.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@ -242,12 +244,12 @@ def tab_mute(tab):
|
|||||||
|
|
||||||
|
|
||||||
@cmdutils.register()
|
@cmdutils.register()
|
||||||
def nop():
|
def nop() -> None:
|
||||||
"""Do nothing."""
|
"""Do nothing."""
|
||||||
|
|
||||||
|
|
||||||
@cmdutils.register()
|
@cmdutils.register()
|
||||||
def message_error(text):
|
def message_error(text: str) -> None:
|
||||||
"""Show an error message in the statusbar.
|
"""Show an error message in the statusbar.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@ -258,7 +260,7 @@ def message_error(text):
|
|||||||
|
|
||||||
@cmdutils.register()
|
@cmdutils.register()
|
||||||
@cmdutils.argument('count', value=cmdutils.Value.count)
|
@cmdutils.argument('count', value=cmdutils.Value.count)
|
||||||
def message_info(text, count=1):
|
def message_info(text: str, count: int = 1) -> None:
|
||||||
"""Show an info message in the statusbar.
|
"""Show an info message in the statusbar.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@ -270,7 +272,7 @@ def message_info(text, count=1):
|
|||||||
|
|
||||||
|
|
||||||
@cmdutils.register()
|
@cmdutils.register()
|
||||||
def message_warning(text):
|
def message_warning(text: str) -> None:
|
||||||
"""Show a warning message in the statusbar.
|
"""Show a warning message in the statusbar.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@ -281,7 +283,7 @@ def message_warning(text):
|
|||||||
|
|
||||||
@cmdutils.register(debug=True)
|
@cmdutils.register(debug=True)
|
||||||
@cmdutils.argument('typ', choices=['exception', 'segfault'])
|
@cmdutils.argument('typ', choices=['exception', 'segfault'])
|
||||||
def debug_crash(typ='exception'):
|
def debug_crash(typ: str = 'exception') -> None:
|
||||||
"""Crash for debugging purposes.
|
"""Crash for debugging purposes.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@ -295,7 +297,7 @@ def debug_crash(typ='exception'):
|
|||||||
|
|
||||||
|
|
||||||
@cmdutils.register(debug=True, maxsplit=0, no_cmd_split=True)
|
@cmdutils.register(debug=True, maxsplit=0, no_cmd_split=True)
|
||||||
def debug_trace(expr=""):
|
def debug_trace(expr: str = "") -> None:
|
||||||
"""Trace executed code via hunter.
|
"""Trace executed code via hunter.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -112,7 +112,7 @@ def scroll_to_perc(tab: apitypes.Tab, count: int = None,
|
|||||||
|
|
||||||
@cmdutils.register()
|
@cmdutils.register()
|
||||||
@cmdutils.argument('tab', value=cmdutils.Value.cur_tab)
|
@cmdutils.argument('tab', value=cmdutils.Value.cur_tab)
|
||||||
def scroll_to_anchor(tab: apitypes.Tab, name):
|
def scroll_to_anchor(tab: apitypes.Tab, name: str) -> None:
|
||||||
"""Scroll to the given anchor in the document.
|
"""Scroll to the given anchor in the document.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -25,7 +25,7 @@ from qutebrowser.api import cmdutils, apitypes, message, config
|
|||||||
@cmdutils.register()
|
@cmdutils.register()
|
||||||
@cmdutils.argument('tab', value=cmdutils.Value.cur_tab)
|
@cmdutils.argument('tab', value=cmdutils.Value.cur_tab)
|
||||||
@cmdutils.argument('count', value=cmdutils.Value.count)
|
@cmdutils.argument('count', value=cmdutils.Value.count)
|
||||||
def zoom_in(tab: apitypes.Tab, count=1, quiet=False):
|
def zoom_in(tab: apitypes.Tab, count: int = 1, quiet: bool = False) -> None:
|
||||||
"""Increase the zoom level for the current tab.
|
"""Increase the zoom level for the current tab.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@ -43,7 +43,7 @@ def zoom_in(tab: apitypes.Tab, count=1, quiet=False):
|
|||||||
@cmdutils.register()
|
@cmdutils.register()
|
||||||
@cmdutils.argument('tab', value=cmdutils.Value.cur_tab)
|
@cmdutils.argument('tab', value=cmdutils.Value.cur_tab)
|
||||||
@cmdutils.argument('count', value=cmdutils.Value.count)
|
@cmdutils.argument('count', value=cmdutils.Value.count)
|
||||||
def zoom_out(tab: apitypes.Tab, count=1, quiet=False):
|
def zoom_out(tab: apitypes.Tab, count: int = 1, quiet: bool = False) -> None:
|
||||||
"""Decrease the zoom level for the current tab.
|
"""Decrease the zoom level for the current tab.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@ -61,7 +61,10 @@ def zoom_out(tab: apitypes.Tab, count=1, quiet=False):
|
|||||||
@cmdutils.register()
|
@cmdutils.register()
|
||||||
@cmdutils.argument('tab', value=cmdutils.Value.cur_tab)
|
@cmdutils.argument('tab', value=cmdutils.Value.cur_tab)
|
||||||
@cmdutils.argument('count', value=cmdutils.Value.count)
|
@cmdutils.argument('count', value=cmdutils.Value.count)
|
||||||
def zoom(tab: apitypes.Tab, level=None, count=None, quiet=False):
|
def zoom(tab: apitypes.Tab,
|
||||||
|
level: str = None,
|
||||||
|
count: int = None,
|
||||||
|
quiet: bool = False) -> None:
|
||||||
"""Set the zoom level for the current tab.
|
"""Set the zoom level for the current tab.
|
||||||
|
|
||||||
The zoom can be given as argument or as [count]. If neither is
|
The zoom can be given as argument or as [count]. If neither is
|
||||||
@ -75,19 +78,19 @@ def zoom(tab: apitypes.Tab, level=None, count=None, quiet=False):
|
|||||||
"""
|
"""
|
||||||
if level is not None:
|
if level is not None:
|
||||||
try:
|
try:
|
||||||
level = int(level.rstrip('%'))
|
int_level = int(level.rstrip('%'))
|
||||||
except ValueError:
|
except ValueError:
|
||||||
raise cmdutils.CommandError("zoom: Invalid int value {}"
|
raise cmdutils.CommandError("zoom: Invalid int value {}"
|
||||||
.format(level))
|
.format(level))
|
||||||
|
|
||||||
if count is not None:
|
if count is not None:
|
||||||
level = count
|
int_level = count
|
||||||
elif level is None:
|
elif int_level is None:
|
||||||
level = config.val.zoom.default
|
int_level = config.val.zoom.default
|
||||||
|
|
||||||
try:
|
try:
|
||||||
tab.zoom.set_factor(float(level) / 100)
|
tab.zoom.set_factor(int_level / 100)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
raise cmdutils.CommandError("Can't zoom {}%!".format(level))
|
raise cmdutils.CommandError("Can't zoom {}%!".format(int_level))
|
||||||
if not quiet:
|
if not quiet:
|
||||||
message.info("Zoom level: {}%".format(int(level)), replace=True)
|
message.info("Zoom level: {}%".format(int_level), replace=True)
|
||||||
|
Loading…
Reference in New Issue
Block a user