Fix some lint
This commit is contained in:
parent
4e5a7a891e
commit
17466b4f26
@ -37,7 +37,7 @@ disable=no-self-use,
|
||||
[BASIC]
|
||||
function-rgx=[a-z_][a-z0-9_]{2,50}$
|
||||
const-rgx=[A-Za-z_][A-Za-z0-9_]{0,30}$
|
||||
method-rgx=[a-z_][A-Za-z0-9_]{2,50}$
|
||||
method-rgx=[a-z_][A-Za-z0-9_]{1,50}$
|
||||
attr-rgx=[a-z_][a-z0-9_]{0,30}$
|
||||
argument-rgx=[a-z_][a-z0-9_]{0,30}$
|
||||
variable-rgx=[a-z_][a-z0-9_]{0,30}$
|
||||
|
@ -21,12 +21,10 @@
|
||||
|
||||
import os
|
||||
import os.path
|
||||
import sys
|
||||
import shlex
|
||||
import posixpath
|
||||
import functools
|
||||
|
||||
from PyQt5.QtWebKit import QWebSettings
|
||||
from PyQt5.QtWidgets import QApplication, QTabBar
|
||||
from PyQt5.QtCore import Qt, QUrl, QEvent
|
||||
from PyQt5.QtGui import QKeyEvent
|
||||
@ -487,7 +485,8 @@ class CommandDispatcher:
|
||||
|
||||
if where in ['prev', 'next']:
|
||||
# FIXME:refactor have a proper API for this
|
||||
frame = widget._widget.page().currentFrame()
|
||||
page = widget._widget.page() # pylint: disable=protected-access
|
||||
frame = page.currentFrame()
|
||||
if frame is None:
|
||||
raise cmdexc.CommandError("No frame focused!")
|
||||
else:
|
||||
@ -1034,12 +1033,11 @@ class CommandDispatcher:
|
||||
env['QUTE_TITLE'] = self._tabbed_browser.page_title(idx)
|
||||
|
||||
tab = self._tabbed_browser.currentWidget()
|
||||
if tab is None:
|
||||
mainframe = None
|
||||
else:
|
||||
if tab.caret.has_selection():
|
||||
env['QUTE_SELECTED_TEXT'] = tab.caret.selection()
|
||||
env['QUTE_SELECTED_HTML'] = tab.caret.selection(html=True)
|
||||
if tab is not None and tab.caret.has_selection():
|
||||
env['QUTE_SELECTED_TEXT'] = tab.caret.selection()
|
||||
env['QUTE_SELECTED_HTML'] = tab.caret.selection(html=True)
|
||||
|
||||
# FIXME:refactor: If tab is None, run_async will fail!
|
||||
|
||||
try:
|
||||
url = self._tabbed_browser.current_url()
|
||||
@ -1112,7 +1110,7 @@ class CommandDispatcher:
|
||||
|
||||
@cmdutils.register(instance='command-dispatcher', hide=True,
|
||||
scope='window')
|
||||
def follow_selected(self, tab=False):
|
||||
def follow_selected(self, *, tab=False):
|
||||
"""Follow the selected text.
|
||||
|
||||
Args:
|
||||
@ -1139,7 +1137,8 @@ class CommandDispatcher:
|
||||
"webinspector!")
|
||||
tab.data.inspector = inspector.WebInspector()
|
||||
# FIXME:refactor have a proper API for this
|
||||
tab.data.inspector.setPage(tab._widget.page())
|
||||
page = tab._widget.page() # pylint: disable=protected-access
|
||||
tab.data.inspector.setPage(page)
|
||||
tab.data.inspector.show()
|
||||
elif tab.data.inspector.isVisible():
|
||||
tab.data.inspector.hide()
|
||||
@ -1188,6 +1187,7 @@ class CommandDispatcher:
|
||||
self._download_mhtml(dest)
|
||||
else:
|
||||
# FIXME:refactor have a proper API for this
|
||||
# pylint: disable=protected-access
|
||||
page = self._current_widget()._widget.page()
|
||||
download_manager.get(self._current_url(), page=page,
|
||||
filename=dest)
|
||||
@ -1224,6 +1224,7 @@ class CommandDispatcher:
|
||||
raise cmdexc.CommandError("Already viewing source!")
|
||||
|
||||
def show_source_cb(source):
|
||||
"""Show source as soon as it's ready."""
|
||||
lexer = pygments.lexers.HtmlLexer()
|
||||
formatter = pygments.formatters.HtmlFormatter(full=True,
|
||||
linenos='table')
|
||||
@ -1252,13 +1253,13 @@ class CommandDispatcher:
|
||||
with open(dest, 'w', encoding='utf-8') as f:
|
||||
f.write(data)
|
||||
except OSError as e:
|
||||
message.error(self._win_id, 'Could not write page: {}'.format(e))
|
||||
message.error(self._win_id,
|
||||
'Could not write page: {}'.format(e))
|
||||
else:
|
||||
message.info(self._win_id, "Dumped page to {}.".format(dest))
|
||||
|
||||
tab.dump_async(callback, plain=plain)
|
||||
|
||||
|
||||
@cmdutils.register(instance='command-dispatcher', name='help',
|
||||
scope='window')
|
||||
@cmdutils.argument('topic', completion=usertypes.Completion.helptopic)
|
||||
@ -1331,9 +1332,10 @@ class CommandDispatcher:
|
||||
`general -> editor` config option.
|
||||
"""
|
||||
# FIXME:refactor have a proper API for this
|
||||
frame = self._current_widget()._widget.page().currentFrame()
|
||||
tab = self._current_widget()
|
||||
page = tab._widget.page() # pylint: disable=protected-access
|
||||
try:
|
||||
elem = webelem.focus_elem(frame)
|
||||
elem = webelem.focus_elem(page.currentFrame())
|
||||
except webelem.IsNullError:
|
||||
raise cmdexc.CommandError("No element focused!")
|
||||
if not elem.is_editable(strict=True):
|
||||
@ -1375,9 +1377,10 @@ class CommandDispatcher:
|
||||
def paste_primary(self):
|
||||
"""Paste the primary selection at cursor position."""
|
||||
# FIXME:refactor have a proper API for this
|
||||
frame = self._current_widget()._widget.page().currentFrame()
|
||||
tab = self._current_widget()
|
||||
page = tab._widget.page() # pylint: disable=protected-access
|
||||
try:
|
||||
elem = webelem.focus_elem(frame)
|
||||
elem = webelem.focus_elem(page.currentFrame())
|
||||
except webelem.IsNullError:
|
||||
raise cmdexc.CommandError("No element focused!")
|
||||
if not elem.is_editable(strict=True):
|
||||
@ -1695,9 +1698,9 @@ class CommandDispatcher:
|
||||
if out is None:
|
||||
# Getting the actual error (if any) seems to be difficult.
|
||||
# The error does end up in
|
||||
# BrowserPage.javaScriptConsoleMessage(), but distinguishing
|
||||
# between :jseval errors and errors from the webpage is not
|
||||
# trivial...
|
||||
# BrowserPage.javaScriptConsoleMessage(), but
|
||||
# distinguishing between :jseval errors and errors from the
|
||||
# webpage is not trivial...
|
||||
message.info(self._win_id, 'No output or error')
|
||||
else:
|
||||
# The output can be a string, number, dict, array, etc. But
|
||||
@ -1705,13 +1708,11 @@ class CommandDispatcher:
|
||||
# qutebrowser hang
|
||||
out = str(out)
|
||||
if len(out) > 5000:
|
||||
message.info(self._win_id, out[:5000] + ' [...trimmed...]')
|
||||
else:
|
||||
message.info(self._win_id, out)
|
||||
out = out[:5000] + ' [...trimmed...]'
|
||||
message.info(self._win_id, out)
|
||||
|
||||
self._current_widget().run_js_async(js_code, callback=jseval_cb)
|
||||
|
||||
|
||||
@cmdutils.register(instance='command-dispatcher', scope='window')
|
||||
def fake_key(self, keystring, global_=False):
|
||||
"""Send a fake keypress or key string to the website or qutebrowser.
|
||||
|
@ -819,7 +819,9 @@ class HintManager(QObject):
|
||||
tab = tabbed_browser.currentWidget()
|
||||
if tab is None:
|
||||
raise cmdexc.CommandError("No WebView available yet!")
|
||||
mainframe = tab._widget.page().mainFrame() # FIXME
|
||||
# FIXME:refactor have a proper API for this
|
||||
page = tab._widget.page() # pylint: disable=protected-access
|
||||
mainframe = page.mainFrame()
|
||||
if mainframe is None:
|
||||
raise cmdexc.CommandError("No frame focused!")
|
||||
mode_manager = objreg.get('mode-manager', scope='window',
|
||||
|
@ -42,28 +42,34 @@ class WebTabError(Exception):
|
||||
|
||||
class WrapperLayout(QLayout):
|
||||
|
||||
"""A Qt layout which simply wraps a single widget.
|
||||
|
||||
This is used so the widget is hidden behind a AbstractTab API and can't
|
||||
easily be accidentally accessed.
|
||||
"""
|
||||
|
||||
def __init__(self, widget, parent=None):
|
||||
super().__init__(parent)
|
||||
self._widget = widget
|
||||
|
||||
def addItem(self, w):
|
||||
def addItem(self, _widget):
|
||||
raise AssertionError("Should never be called!")
|
||||
|
||||
def sizeHint(self):
|
||||
return self._widget.sizeHint()
|
||||
|
||||
def itemAt(self, i):
|
||||
def itemAt(self, _index):
|
||||
# FIXME why does this get called?
|
||||
return None
|
||||
|
||||
def takeAt(self, i):
|
||||
def takeAt(self, _index):
|
||||
raise AssertionError("Should never be called!")
|
||||
|
||||
def setGeometry(self, r):
|
||||
self._widget.setGeometry(r)
|
||||
def setGeometry(self, rect):
|
||||
self._widget.setGeometry(rect)
|
||||
|
||||
|
||||
class TabData(QObject):
|
||||
class TabData:
|
||||
|
||||
"""A simple namespace with a fixed set of attributes.
|
||||
|
||||
@ -82,7 +88,8 @@ class TabData(QObject):
|
||||
|
||||
def __getattr__(self, attr):
|
||||
if attr.startswith('_'):
|
||||
return super().__getattr__(attr)
|
||||
# WORKAROUND for https://github.com/PyCQA/pylint/issues/979
|
||||
return super().__getattr__(attr) # pylint: disable=no-member
|
||||
try:
|
||||
return self._data[attr]
|
||||
except KeyError:
|
||||
@ -92,7 +99,8 @@ class TabData(QObject):
|
||||
if attr.startswith('_'):
|
||||
return super().__setattr__(attr, value)
|
||||
if attr not in self._data:
|
||||
raise AttributeError("Can't set unknown attribute {!r}".format(attr))
|
||||
msg = "Can't set unknown attribute {!r}".format(attr)
|
||||
raise AttributeError(msg)
|
||||
self._data[attr] = value
|
||||
|
||||
|
||||
@ -218,6 +226,7 @@ class AbstractZoom(QObject):
|
||||
if factor < 0:
|
||||
return
|
||||
perc = int(100 * factor)
|
||||
# FIXME move this somewhere else?
|
||||
message.info(self.win_id, "Zoom level: {}%".format(perc))
|
||||
self._neighborlist.fuzzyval = perc
|
||||
self._set_factor_internal(factor)
|
||||
@ -300,7 +309,7 @@ class AbstractCaret(QObject):
|
||||
def selection(self, html=False):
|
||||
raise NotImplementedError
|
||||
|
||||
def follow_selected(self, tab=False):
|
||||
def follow_selected(self, *, tab=False):
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
@ -452,6 +461,7 @@ class AbstractTab(QWidget):
|
||||
self.backend = None
|
||||
|
||||
def _set_widget(self, widget):
|
||||
# pylint: disable=protected-access
|
||||
self._layout = WrapperLayout(widget, self)
|
||||
self._widget = widget
|
||||
self.history._history = widget.history()
|
||||
|
@ -24,16 +24,19 @@ from PyQt5.QtGui import QKeyEvent
|
||||
from PyQt5.QtWidgets import QApplication
|
||||
|
||||
try:
|
||||
from PyQt5.QtWebEngineWidgets import QWebEngineView, QWebEnginePage
|
||||
from PyQt5.QtWebEngineWidgets import QWebEnginePage
|
||||
except ImportError:
|
||||
QWebEngineView = None
|
||||
QWebEnginePage = None
|
||||
|
||||
from qutebrowser.browser import tab
|
||||
from qutebrowser.browser.webengine import webview
|
||||
from qutebrowser.utils import usertypes, qtutils
|
||||
|
||||
|
||||
## FIXME:refactor add stubs for abstract things which aren't implemented yet.
|
||||
## pylint: disable=abstract-method
|
||||
|
||||
|
||||
class WebEngineSearch(tab.AbstractSearch):
|
||||
|
||||
## TODO
|
||||
@ -66,7 +69,7 @@ class WebEngineCaret(tab.AbstractCaret):
|
||||
|
||||
class WebEngineScroller(tab.AbstractScroller):
|
||||
|
||||
def _key_press(self, key, count=1, getter_name=None, direction=None):
|
||||
def _key_press(self, key, count=1):
|
||||
# FIXME for some reason this does not work? :-/
|
||||
# FIXME Abort scrolling if the minimum/maximum was reached.
|
||||
press_evt = QKeyEvent(QEvent.KeyPress, key, Qt.NoModifier, 0, 0, 0)
|
||||
@ -91,16 +94,16 @@ class WebEngineScroller(tab.AbstractScroller):
|
||||
return (perc_x, perc_y)
|
||||
|
||||
def up(self, count=1):
|
||||
self._key_press(Qt.Key_Up, count, 'scrollBarMinimum', Qt.Vertical)
|
||||
self._key_press(Qt.Key_Up, count)
|
||||
|
||||
def down(self, count=1):
|
||||
self._key_press(Qt.Key_Down, count, 'scrollBarMaximum', Qt.Vertical)
|
||||
self._key_press(Qt.Key_Down, count)
|
||||
|
||||
def left(self, count=1):
|
||||
self._key_press(Qt.Key_Left, count, 'scrollBarMinimum', Qt.Horizontal)
|
||||
self._key_press(Qt.Key_Left, count)
|
||||
|
||||
def right(self, count=1):
|
||||
self._key_press(Qt.Key_Right, count, 'scrollBarMaximum', Qt.Horizontal)
|
||||
self._key_press(Qt.Key_Right, count)
|
||||
|
||||
def top(self):
|
||||
self._key_press(Qt.Key_Home)
|
||||
@ -109,11 +112,10 @@ class WebEngineScroller(tab.AbstractScroller):
|
||||
self._key_press(Qt.Key_End)
|
||||
|
||||
def page_up(self, count=1):
|
||||
self._key_press(Qt.Key_PageUp, count, 'scrollBarMinimum', Qt.Vertical)
|
||||
self._key_press(Qt.Key_PageUp, count)
|
||||
|
||||
def page_down(self, count=1):
|
||||
self._key_press(Qt.Key_PageDown, count, 'scrollBarMaximum',
|
||||
Qt.Vertical)
|
||||
self._key_press(Qt.Key_PageDown, count)
|
||||
|
||||
## TODO
|
||||
|
||||
|
@ -26,6 +26,8 @@ from PyQt5.QtWebEngineWidgets import QWebEngineView
|
||||
|
||||
class WebEngineView(QWebEngineView):
|
||||
|
||||
"""Custom QWebEngineView subclass with qutebrowser-specific features."""
|
||||
|
||||
mouse_wheel_zoom = pyqtSignal(QPoint)
|
||||
|
||||
def wheelEvent(self, e):
|
||||
|
@ -255,7 +255,8 @@ class _Downloader:
|
||||
web_url = self.web_view.cur_url
|
||||
|
||||
# FIXME:refactor have a proper API for this
|
||||
web_frame = self.web_view._widget.page().mainFrame()
|
||||
page = self.web_view._widget.page() # pylint: disable=protected-access
|
||||
web_frame = page.mainFrame()
|
||||
|
||||
self.writer = MHTMLWriter(
|
||||
web_frame.toHtml().encode('utf-8'),
|
||||
|
@ -28,12 +28,12 @@ from PyQt5.QtGui import QKeyEvent
|
||||
from PyQt5.QtWebKitWidgets import QWebPage
|
||||
from PyQt5.QtWebKit import QWebSettings
|
||||
|
||||
from qutebrowser.browser import tab
|
||||
from qutebrowser.browser import tab as tabmod
|
||||
from qutebrowser.browser.webkit import webview, tabhistory
|
||||
from qutebrowser.utils import qtutils, objreg, usertypes, utils
|
||||
|
||||
|
||||
class WebViewSearch(tab.AbstractSearch):
|
||||
class WebViewSearch(tabmod.AbstractSearch):
|
||||
|
||||
def clear(self):
|
||||
# We first clear the marked text, then the highlights
|
||||
@ -73,7 +73,7 @@ class WebViewSearch(tab.AbstractSearch):
|
||||
self._widget.search(self.text, flags)
|
||||
|
||||
|
||||
class WebViewCaret(tab.AbstractCaret):
|
||||
class WebViewCaret(tabmod.AbstractCaret):
|
||||
|
||||
@pyqtSlot(usertypes.KeyMode)
|
||||
def on_mode_entered(self, mode):
|
||||
@ -99,8 +99,8 @@ class WebViewCaret(tab.AbstractCaret):
|
||||
self._widget.page().currentFrame().evaluateJavaScript(
|
||||
utils.read_file('javascript/position_caret.js'))
|
||||
|
||||
@pyqtSlot(usertypes.KeyMode)
|
||||
def on_mode_left(self, mode):
|
||||
@pyqtSlot()
|
||||
def on_mode_left(self):
|
||||
settings = self._widget.settings()
|
||||
if settings.testAttribute(QWebSettings.CaretBrowsingEnabled):
|
||||
if self.selection_enabled and self._widget.hasSelection():
|
||||
@ -277,13 +277,13 @@ class WebViewCaret(tab.AbstractCaret):
|
||||
selected_element = xml.etree.ElementTree.fromstring(
|
||||
'<html>{}</html>'.format(selection)).find('a')
|
||||
except xml.etree.ElementTree.ParseError:
|
||||
raise tab.WebTabError('Could not parse selected element!')
|
||||
raise tabmod.WebTabError('Could not parse selected element!')
|
||||
|
||||
if selected_element is not None:
|
||||
try:
|
||||
url = selected_element.attrib['href']
|
||||
except KeyError:
|
||||
raise tab.WebTabError('Anchor element without href!')
|
||||
raise tabmod.WebTabError('Anchor element without href!')
|
||||
url = self._tab.cur_url.resolved(QUrl(url))
|
||||
if tab:
|
||||
self._tab.new_tab_requested.emit(url)
|
||||
@ -291,7 +291,7 @@ class WebViewCaret(tab.AbstractCaret):
|
||||
self._tab.openurl(url)
|
||||
|
||||
|
||||
class WebViewZoom(tab.AbstractZoom):
|
||||
class WebViewZoom(tabmod.AbstractZoom):
|
||||
|
||||
def _set_factor_internal(self, factor):
|
||||
self._widget.setZoomFactor(factor)
|
||||
@ -300,7 +300,7 @@ class WebViewZoom(tab.AbstractZoom):
|
||||
return self._widget.zoomFactor()
|
||||
|
||||
|
||||
class WebViewScroller(tab.AbstractScroller):
|
||||
class WebViewScroller(tabmod.AbstractScroller):
|
||||
|
||||
def pos_px(self):
|
||||
return self._widget.page().mainFrame().scrollPosition()
|
||||
@ -316,7 +316,7 @@ class WebViewScroller(tab.AbstractScroller):
|
||||
qtutils.check_overflow(y, 'int')
|
||||
self._widget.page().mainFrame().scroll(x, y)
|
||||
|
||||
def delta_page(self, x=0, y=0):
|
||||
def delta_page(self, x=0.0, y=0.0):
|
||||
if y.is_integer():
|
||||
y = int(y)
|
||||
if y == 0:
|
||||
@ -339,7 +339,7 @@ class WebViewScroller(tab.AbstractScroller):
|
||||
else:
|
||||
for val, orientation in [(x, Qt.Horizontal), (y, Qt.Vertical)]:
|
||||
if val is not None:
|
||||
perc = qtutils.check_overflow(val, 'int', fatal=False)
|
||||
val = qtutils.check_overflow(val, 'int', fatal=False)
|
||||
frame = self._widget.page().mainFrame()
|
||||
m = frame.scrollBarMaximum(orientation)
|
||||
if m == 0:
|
||||
@ -396,7 +396,7 @@ class WebViewScroller(tab.AbstractScroller):
|
||||
return self.pos_px().y() >= frame.scrollBarMaximum(Qt.Vertical)
|
||||
|
||||
|
||||
class WebViewHistory(tab.AbstractHistory):
|
||||
class WebViewHistory(tabmod.AbstractHistory):
|
||||
|
||||
def current_idx(self):
|
||||
return self._history.currentItemIndex()
|
||||
@ -434,7 +434,7 @@ class WebViewHistory(tab.AbstractHistory):
|
||||
self._tab.scroll.to_point, cur_data['scroll-pos']))
|
||||
|
||||
|
||||
class WebViewTab(tab.AbstractTab):
|
||||
class WebViewTab(tabmod.AbstractTab):
|
||||
|
||||
def __init__(self, win_id, modeman, parent=None):
|
||||
super().__init__(win_id)
|
||||
@ -447,8 +447,8 @@ class WebViewTab(tab.AbstractTab):
|
||||
self.search = WebViewSearch(parent=self)
|
||||
self._set_widget(widget)
|
||||
self._connect_signals()
|
||||
self.zoom._set_default_zoom()
|
||||
self.backend = tab.Backend.QtWebKit
|
||||
self.zoom._set_default_zoom() # pylint: disable=protected-access
|
||||
self.backend = tabmod.Backend.QtWebKit
|
||||
|
||||
def openurl(self, url):
|
||||
self._widget.openurl(url)
|
||||
@ -520,9 +520,9 @@ class WebViewTab(tab.AbstractTab):
|
||||
view.load_status_changed.connect(self.load_status_changed)
|
||||
view.shutting_down.connect(self.shutting_down)
|
||||
|
||||
# Make sure we emit an appropriate status when loading finished.
|
||||
# While Qt has a bool "ok" attribute for loadFinished, it always is True
|
||||
# when using error pages...
|
||||
# Make sure we emit an appropriate status when loading finished. While
|
||||
# Qt has a bool "ok" attribute for loadFinished, it always is True when
|
||||
# using error pages...
|
||||
# See https://github.com/The-Compiler/qutebrowser/issues/84
|
||||
frame.loadFinished.connect(lambda:
|
||||
self.load_finished.emit(
|
||||
|
@ -21,8 +21,7 @@
|
||||
|
||||
import functools
|
||||
|
||||
from PyQt5.QtCore import (pyqtSlot, pyqtSignal, PYQT_VERSION, Qt, QUrl, QPoint,
|
||||
QTimer)
|
||||
from PyQt5.QtCore import pyqtSlot, pyqtSignal, PYQT_VERSION, Qt, QUrl, QPoint
|
||||
from PyQt5.QtGui import QDesktopServices
|
||||
from PyQt5.QtNetwork import QNetworkReply, QNetworkRequest
|
||||
from PyQt5.QtWidgets import QFileDialog
|
||||
@ -31,7 +30,7 @@ from PyQt5.QtWebKitWidgets import QWebPage
|
||||
|
||||
from qutebrowser.config import config
|
||||
from qutebrowser.browser import pdfjs
|
||||
from qutebrowser.browser.webkit import http, tabhistory
|
||||
from qutebrowser.browser.webkit import http
|
||||
from qutebrowser.browser.webkit.network import networkmanager
|
||||
from qutebrowser.utils import (message, usertypes, log, jinja, qtutils, utils,
|
||||
objreg, debug, urlutils)
|
||||
|
@ -20,8 +20,6 @@
|
||||
"""The main browser widgets."""
|
||||
|
||||
import sys
|
||||
import itertools
|
||||
import functools
|
||||
|
||||
from PyQt5.QtCore import pyqtSignal, pyqtSlot, Qt, QTimer, QUrl, QPoint
|
||||
from PyQt5.QtGui import QPalette
|
||||
@ -38,9 +36,7 @@ from qutebrowser.browser.webkit import webpage, webelem
|
||||
|
||||
class WebView(QWebView):
|
||||
|
||||
"""One browser tab in TabbedBrowser.
|
||||
|
||||
Our own subclass of a QWebView with some added bells and whistles.
|
||||
"""Custom QWebView subclass with qutebrowser-specific features.
|
||||
|
||||
Attributes:
|
||||
tab: The WebKitTab object for this WebView
|
||||
@ -495,6 +491,7 @@ class WebView(QWebView):
|
||||
"support that!")
|
||||
tabbed_browser = objreg.get('tabbed-browser', scope='window',
|
||||
window=self.win_id)
|
||||
# pylint: disable=protected-access
|
||||
return tabbed_browser.tabopen(background=False)._widget
|
||||
|
||||
def paintEvent(self, e):
|
||||
|
@ -26,7 +26,7 @@ import tempfile
|
||||
from PyQt5.QtCore import pyqtSignal, pyqtSlot, QObject, QSocketNotifier
|
||||
|
||||
from qutebrowser.utils import message, log, objreg, standarddir
|
||||
from qutebrowser.commands import runners, cmdexc
|
||||
from qutebrowser.commands import runners
|
||||
from qutebrowser.config import config
|
||||
from qutebrowser.misc import guiprocess
|
||||
from qutebrowser.browser.webkit import downloads
|
||||
|
@ -330,7 +330,7 @@ class StatusBar(QWidget):
|
||||
self._command_active = val
|
||||
elif mode == usertypes.KeyMode.caret:
|
||||
tab = objreg.get('tabbed-browser', scope='window',
|
||||
window=self._win_id).currentWidget()
|
||||
window=self._win_id).currentWidget()
|
||||
log.statusbar.debug("Setting caret_mode - val {}, selection "
|
||||
"{}".format(val, tab.caret.selection_enabled))
|
||||
if val:
|
||||
|
@ -381,7 +381,6 @@ class TabbedBrowser(tabwidget.TabWidget):
|
||||
window=window.win_id)
|
||||
return tabbed_browser.tabopen(url, background, explicit)
|
||||
|
||||
|
||||
if objreg.get('args').backend == 'webengine':
|
||||
tab_class = webenginetab.WebEngineViewTab
|
||||
else:
|
||||
|
@ -29,7 +29,6 @@ from PyQt5.QtGui import QIcon, QPalette, QColor
|
||||
|
||||
from qutebrowser.utils import qtutils, objreg, utils, usertypes
|
||||
from qutebrowser.config import config
|
||||
from qutebrowser.browser.webkit import webview
|
||||
|
||||
|
||||
PixelMetrics = usertypes.enum('PixelMetrics', ['icon_padding'],
|
||||
|
@ -251,8 +251,6 @@ LoadStatus = enum('LoadStatus', ['none', 'success', 'success_https', 'error',
|
||||
'warn', 'loading'])
|
||||
|
||||
|
||||
|
||||
|
||||
class Question(QObject):
|
||||
|
||||
"""A question asked to the user, e.g. via the status bar.
|
||||
|
@ -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/>.
|
||||
|
||||
# pylint: disable=invalid-name
|
||||
# pylint: disable=invalid-name,abstract-method
|
||||
|
||||
"""Fake objects/stubs."""
|
||||
|
||||
@ -27,7 +27,7 @@ from unittest import mock
|
||||
from PyQt5.QtCore import pyqtSignal, QPoint, QProcess, QObject
|
||||
from PyQt5.QtNetwork import (QNetworkRequest, QAbstractNetworkCache,
|
||||
QNetworkCacheMetaData)
|
||||
from PyQt5.QtWidgets import QCommonStyle, QWidget, QLineEdit
|
||||
from PyQt5.QtWidgets import QCommonStyle, QLineEdit
|
||||
|
||||
from qutebrowser.browser import tab
|
||||
from qutebrowser.browser.webkit import webview, history
|
||||
@ -227,6 +227,8 @@ def fake_qprocess():
|
||||
|
||||
class FakeWebTabScroller(tab.AbstractScroller):
|
||||
|
||||
"""Fake AbstractScroller to use in tests."""
|
||||
|
||||
def __init__(self, pos_perc):
|
||||
super().__init__()
|
||||
self._pos_perc = pos_perc
|
||||
|
@ -86,13 +86,13 @@ class TestTabData:
|
||||
|
||||
def test_known_attr(self):
|
||||
data = tab.TabData()
|
||||
assert data.keep_icon == False
|
||||
assert not data.keep_icon
|
||||
data.keep_icon = True
|
||||
assert data.keep_icon == True
|
||||
assert data.keep_icon
|
||||
|
||||
def test_unknown_attr(self):
|
||||
data = tab.TabData()
|
||||
with pytest.raises(AttributeError):
|
||||
data.bar = 42
|
||||
with pytest.raises(AttributeError):
|
||||
data.bar
|
||||
data.bar # pylint: disable=pointless-statement
|
||||
|
@ -26,7 +26,7 @@ import signal
|
||||
import pytest
|
||||
from PyQt5.QtCore import QFileSystemWatcher
|
||||
|
||||
from qutebrowser.commands import userscripts, cmdexc
|
||||
from qutebrowser.commands import userscripts
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
@ -235,5 +235,5 @@ def test_unsupported(monkeypatch, tabbed_browser_stubs):
|
||||
monkeypatch.setattr(userscripts.os, 'name', 'toaster')
|
||||
with pytest.raises(userscripts.UnsupportedError) as excinfo:
|
||||
userscripts.run_async(tab=None, cmd=None, win_id=0, env=None)
|
||||
expected ="Userscripts are not supported on this platform!"
|
||||
expected = "Userscripts are not supported on this platform!"
|
||||
assert str(excinfo.value) == expected
|
||||
|
Loading…
Reference in New Issue
Block a user