Fix types in @pyqtSlot decorations
PyQt 5.5 enforces correct type signatures, and there were a lot of places where we were simply wrong, causing qutebrowser to not start at all...
This commit is contained in:
parent
da24e43fa5
commit
37b5f49c85
@ -231,7 +231,7 @@ class DownloadItemStats(QObject):
|
||||
else:
|
||||
return remaining_bytes / avg
|
||||
|
||||
@pyqtSlot(int, int)
|
||||
@pyqtSlot('qint64', 'qint64')
|
||||
def on_download_progress(self, bytes_done, bytes_total):
|
||||
"""Update local variables when the download progress changed.
|
||||
|
||||
@ -650,7 +650,7 @@ class DownloadItem(QObject):
|
||||
except OSError as e:
|
||||
self._die(e.strerror)
|
||||
|
||||
@pyqtSlot(int)
|
||||
@pyqtSlot('QNetworkReply::NetworkError')
|
||||
def on_reply_error(self, code):
|
||||
"""Handle QNetworkReply errors."""
|
||||
if code == QNetworkReply.OperationCanceledError:
|
||||
|
@ -253,7 +253,7 @@ class NetworkManager(QNetworkAccessManager):
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
@pyqtSlot('QNetworkReply', 'QAuthenticator')
|
||||
@pyqtSlot('QNetworkReply*', 'QAuthenticator*')
|
||||
def on_authentication_required(self, reply, authenticator):
|
||||
"""Called when a website needs authentication."""
|
||||
user, password = None, None
|
||||
@ -286,7 +286,7 @@ class NetworkManager(QNetworkAccessManager):
|
||||
authenticator.setUser(user)
|
||||
authenticator.setPassword(password)
|
||||
|
||||
@pyqtSlot('QNetworkProxy', 'QAuthenticator')
|
||||
@pyqtSlot('QNetworkProxy', 'QAuthenticator*')
|
||||
def on_proxy_authentication_required(self, proxy, authenticator):
|
||||
"""Called when a proxy needs authentication."""
|
||||
proxy_id = ProxyId(proxy.type(), proxy.hostName(), proxy.port())
|
||||
|
@ -288,7 +288,7 @@ class BrowserPage(QWebPage):
|
||||
window=self._win_id)
|
||||
download_manager.get_request(req, page=self)
|
||||
|
||||
@pyqtSlot('QNetworkReply')
|
||||
@pyqtSlot('QNetworkReply*')
|
||||
def on_unsupported_content(self, reply):
|
||||
"""Handle an unsupportedContent signal.
|
||||
|
||||
@ -334,7 +334,7 @@ class BrowserPage(QWebPage):
|
||||
else:
|
||||
self.error_occurred = False
|
||||
|
||||
@pyqtSlot('QWebFrame', 'QWebPage::Feature')
|
||||
@pyqtSlot('QWebFrame*', 'QWebPage::Feature')
|
||||
def on_feature_permission_requested(self, frame, feature):
|
||||
"""Ask the user for approval for geolocation/notifications."""
|
||||
options = {
|
||||
@ -439,7 +439,7 @@ class BrowserPage(QWebPage):
|
||||
if 'scroll-pos' in data and frame.scrollPosition() == QPoint(0, 0):
|
||||
frame.setScrollPosition(data['scroll-pos'])
|
||||
|
||||
@pyqtSlot(str)
|
||||
@pyqtSlot(usertypes.ClickTarget)
|
||||
def on_start_hinting(self, hint_target):
|
||||
"""Emitted before a hinting-click takes place.
|
||||
|
||||
|
@ -352,7 +352,7 @@ class WebView(QWebView):
|
||||
frame = self.page().mainFrame()
|
||||
frame.javaScriptWindowObjectCleared.connect(self.add_js_bridge)
|
||||
|
||||
@pyqtSlot(QWebFrame)
|
||||
@pyqtSlot()
|
||||
def add_js_bridge(self):
|
||||
"""Add the javascript bridge for qute:... pages."""
|
||||
frame = self.sender()
|
||||
|
@ -258,6 +258,7 @@ class CommandRunner(QObject):
|
||||
result.cmd.run(self._win_id, args)
|
||||
|
||||
@pyqtSlot(str, int)
|
||||
@pyqtSlot(str)
|
||||
def run_safely(self, text, count=None):
|
||||
"""Run a command and display exceptions in the statusbar."""
|
||||
try:
|
||||
|
@ -26,6 +26,7 @@ from qutebrowser.config import config, configdata
|
||||
from qutebrowser.utils import objreg, log
|
||||
from qutebrowser.commands import cmdutils
|
||||
from qutebrowser.completion.models import base
|
||||
from qutebrowser.mainwindow import mainwindow
|
||||
|
||||
|
||||
class CommandCompletionModel(base.BaseCompletionModel):
|
||||
@ -176,9 +177,7 @@ class TabCompletionModel(base.BaseCompletionModel):
|
||||
objreg.get("app").new_window.connect(self.on_new_window)
|
||||
self.rebuild()
|
||||
|
||||
# slot argument should be mainwindow.MainWindow but can't import
|
||||
# that at module level because of import loops.
|
||||
@pyqtSlot(object)
|
||||
@pyqtSlot(mainwindow.MainWindow)
|
||||
def on_new_window(self, window):
|
||||
"""Add hooks to new windows."""
|
||||
window.tabbed_browser.new_tab.connect(self.on_new_tab)
|
||||
|
@ -95,6 +95,7 @@ class change_filter: # pylint: disable=invalid-name
|
||||
"""
|
||||
if self._function:
|
||||
@pyqtSlot(str, str)
|
||||
@pyqtSlot()
|
||||
@functools.wraps(func)
|
||||
def wrapper(sectname=None, optname=None):
|
||||
if sectname is None and optname is None:
|
||||
@ -108,6 +109,7 @@ class change_filter: # pylint: disable=invalid-name
|
||||
return func()
|
||||
else:
|
||||
@pyqtSlot(str, str)
|
||||
@pyqtSlot()
|
||||
@functools.wraps(func)
|
||||
def wrapper(wrapper_self, sectname=None, optname=None):
|
||||
if sectname is None and optname is None:
|
||||
|
@ -22,6 +22,7 @@
|
||||
from PyQt5.QtCore import pyqtSlot
|
||||
|
||||
from qutebrowser.mainwindow.statusbar import textbase
|
||||
from qutebrowser.browser import webview
|
||||
|
||||
|
||||
class Percentage(textbase.TextBase):
|
||||
@ -48,7 +49,7 @@ class Percentage(textbase.TextBase):
|
||||
else:
|
||||
self.setText('[{:2}%]'.format(y))
|
||||
|
||||
@pyqtSlot(object)
|
||||
@pyqtSlot(webview.WebView)
|
||||
def on_tab_changed(self, tab):
|
||||
"""Update scroll position when tab changed."""
|
||||
self.set_perc(*tab.scroll_pos)
|
||||
|
@ -59,7 +59,7 @@ class Progress(QProgressBar):
|
||||
self.setValue(0)
|
||||
self.show()
|
||||
|
||||
@pyqtSlot(int)
|
||||
@pyqtSlot(webview.WebView)
|
||||
def on_tab_changed(self, tab):
|
||||
"""Set the correct value when the current tab changed."""
|
||||
if self is None: # pragma: no branch
|
||||
|
@ -24,6 +24,7 @@ from PyQt5.QtCore import pyqtSlot
|
||||
from qutebrowser.config import config
|
||||
from qutebrowser.mainwindow.statusbar import textbase
|
||||
from qutebrowser.utils import usertypes, log, objreg
|
||||
from qutebrowser.browser import webview
|
||||
|
||||
|
||||
class Text(textbase.TextBase):
|
||||
@ -98,7 +99,7 @@ class Text(textbase.TextBase):
|
||||
"""Clear jstext when page loading started."""
|
||||
self._jstext = ''
|
||||
|
||||
@pyqtSlot(int)
|
||||
@pyqtSlot(webview.WebView)
|
||||
def on_tab_changed(self, tab):
|
||||
"""Set the correct jstext when the current tab changed."""
|
||||
self._jstext = tab.statusbar_message
|
||||
|
@ -158,7 +158,7 @@ class UrlText(textbase.TextBase):
|
||||
self._hover_url = None
|
||||
self._update_url()
|
||||
|
||||
@pyqtSlot(int)
|
||||
@pyqtSlot(webview.WebView)
|
||||
def on_tab_changed(self, tab):
|
||||
"""Update URL if the tab changed."""
|
||||
self._hover_url = None
|
||||
|
@ -221,7 +221,7 @@ class IPCServer(QObject):
|
||||
# This means we only use setSocketOption on Windows...
|
||||
os.chmod(self._server.fullServerName(), 0o700)
|
||||
|
||||
@pyqtSlot(int)
|
||||
@pyqtSlot('QLocalSocket::LocalSocketError')
|
||||
def on_error(self, err):
|
||||
"""Raise SocketError on fatal errors."""
|
||||
if self._socket is None:
|
||||
|
Loading…
Reference in New Issue
Block a user