qt6 mypy: Remove PyQt5 type ignores
This commit is contained in:
parent
d13bd0675d
commit
42f0ee36e3
|
|
@ -1332,7 +1332,7 @@ class AbstractTab(QWidget):
|
|||
try:
|
||||
qurl = self.url()
|
||||
as_unicode = QUrl.ComponentFormattingOption.EncodeUnicode
|
||||
url = qurl.toDisplayString(as_unicode) # type: ignore[arg-type]
|
||||
url = qurl.toDisplayString(as_unicode)
|
||||
except (AttributeError, RuntimeError) as exc:
|
||||
url = '<{}>'.format(exc.__class__.__name__)
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -732,7 +732,7 @@ class CommandDispatcher:
|
|||
if key in config.val.url.yank_ignored_parameters:
|
||||
url_query.removeQueryItem(key)
|
||||
url.setQuery(url_query)
|
||||
return url.toString(flags) # type: ignore[arg-type]
|
||||
return url.toString(flags)
|
||||
|
||||
@cmdutils.register(instance='command-dispatcher', scope='window')
|
||||
@cmdutils.argument('what', choices=['selection', 'url', 'pretty-url',
|
||||
|
|
|
|||
|
|
@ -254,7 +254,7 @@ class HintActions:
|
|||
|
||||
flags = QUrl.ComponentFormattingOption.FullyEncoded | QUrl.UrlFormattingOption.RemovePassword
|
||||
if url.scheme() == 'mailto':
|
||||
flags |= QUrl.UrlFormattingOption.RemoveScheme # type: ignore[operator]
|
||||
flags |= QUrl.UrlFormattingOption.RemoveScheme
|
||||
urlstr = url.toString(flags)
|
||||
|
||||
new_content = urlstr
|
||||
|
|
@ -276,7 +276,7 @@ class HintActions:
|
|||
|
||||
def run_cmd(self, url: QUrl, context: HintContext) -> None:
|
||||
"""Run the command based on a hint URL."""
|
||||
urlstr = url.toString(QUrl.ComponentFormattingOption.FullyEncoded) # type: ignore[arg-type]
|
||||
urlstr = url.toString(QUrl.ComponentFormattingOption.FullyEncoded)
|
||||
args = context.get_args(urlstr)
|
||||
commandrunner = runners.CommandRunner(self._win_id)
|
||||
commandrunner.run_safely(' '.join(args))
|
||||
|
|
@ -284,7 +284,7 @@ class HintActions:
|
|||
def preset_cmd_text(self, url: QUrl, context: HintContext) -> None:
|
||||
"""Preset a commandline text based on a hint URL."""
|
||||
flags = QUrl.ComponentFormattingOption.FullyEncoded
|
||||
urlstr = url.toDisplayString(flags) # type: ignore[arg-type]
|
||||
urlstr = url.toDisplayString(flags)
|
||||
args = context.get_args(urlstr)
|
||||
text = ' '.join(args)
|
||||
if text[0] not in modeparsers.STARTCHARS:
|
||||
|
|
@ -331,13 +331,12 @@ class HintActions:
|
|||
'QUTE_MODE': 'hints',
|
||||
'QUTE_SELECTED_TEXT': str(elem),
|
||||
'QUTE_SELECTED_HTML': elem.outer_xml(),
|
||||
'QUTE_CURRENT_URL':
|
||||
context.baseurl.toString(flags), # type: ignore[arg-type]
|
||||
'QUTE_CURRENT_URL': context.baseurl.toString(flags),
|
||||
}
|
||||
|
||||
url = elem.resolve_url(context.baseurl)
|
||||
if url is not None:
|
||||
env['QUTE_URL'] = url.toString(flags) # type: ignore[arg-type]
|
||||
env['QUTE_URL'] = url.toString(flags)
|
||||
|
||||
try:
|
||||
userscripts.run_async(context.tab, cmd, *args, win_id=self._win_id,
|
||||
|
|
|
|||
|
|
@ -95,8 +95,7 @@ def _generate_pdfjs_script(filename):
|
|||
url_query.addQueryItem('filename', filename)
|
||||
url.setQuery(url_query)
|
||||
|
||||
js_url = javascript.to_js(
|
||||
url.toString(QUrl.ComponentFormattingOption.FullyEncoded)) # type: ignore[arg-type]
|
||||
js_url = javascript.to_js(url.toString(QUrl.ComponentFormattingOption.FullyEncoded))
|
||||
|
||||
return jinja.js_environment.from_string("""
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
|
|
@ -245,7 +244,7 @@ def get_main_url(filename: str, original_url: QUrl) -> QUrl:
|
|||
query = QUrlQuery()
|
||||
query.addQueryItem('filename', filename) # read from our JS
|
||||
query.addQueryItem('file', '') # to avoid pdfjs opening the default PDF
|
||||
urlstr = original_url.toString(QUrl.ComponentFormattingOption.FullyEncoded) # type: ignore[arg-type]
|
||||
urlstr = original_url.toString(QUrl.ComponentFormattingOption.FullyEncoded)
|
||||
query.addQueryItem('source', urlstr)
|
||||
url.setQuery(query)
|
||||
return url
|
||||
|
|
|
|||
|
|
@ -229,9 +229,7 @@ def handle_certificate_error(
|
|||
# scheme might not match.
|
||||
is_resource = (
|
||||
first_party_url.isValid() and
|
||||
not request_url.matches(
|
||||
first_party_url,
|
||||
QUrl.UrlFormattingOption.RemoveScheme)) # type: ignore[arg-type]
|
||||
not request_url.matches(first_party_url, QUrl.UrlFormattingOption.RemoveScheme))
|
||||
|
||||
if conf == 'ask' or conf == 'ask-block-thirdparty' and not is_resource:
|
||||
err_template = jinja.environment.from_string("""
|
||||
|
|
@ -261,7 +259,7 @@ def handle_certificate_error(
|
|||
error=error,
|
||||
)
|
||||
urlstr = request_url.toString(
|
||||
QUrl.UrlFormattingOption.RemovePassword | QUrl.ComponentFormattingOption.FullyEncoded) # type: ignore[arg-type]
|
||||
QUrl.UrlFormattingOption.RemovePassword | QUrl.ComponentFormattingOption.FullyEncoded)
|
||||
title = "Certificate error"
|
||||
|
||||
try:
|
||||
|
|
|
|||
|
|
@ -1180,7 +1180,7 @@ class DBusNotificationAdapter(AbstractNotificationAdapter):
|
|||
prefix = None
|
||||
elif self._capabilities.body_markup and self._capabilities.body_hyperlinks:
|
||||
href = html.escape(
|
||||
origin_url.toString(QUrl.ComponentFormattingOption.FullyEncoded) # type: ignore[arg-type]
|
||||
origin_url.toString(QUrl.ComponentFormattingOption.FullyEncoded)
|
||||
)
|
||||
text = html.escape(urlstr, quote=False)
|
||||
prefix = f'<a href="{href}">{text}</a>'
|
||||
|
|
|
|||
|
|
@ -1437,8 +1437,7 @@ class WebEngineTab(browsertab.AbstractTab):
|
|||
title = self.title()
|
||||
title_url = QUrl(url)
|
||||
title_url.setScheme('')
|
||||
title_url_str = title_url.toDisplayString(
|
||||
QUrl.UrlFormattingOption.RemoveScheme) # type: ignore[arg-type]
|
||||
title_url_str = title_url.toDisplayString(QUrl.UrlFormattingOption.RemoveScheme)
|
||||
if title == title_url_str.strip('/'):
|
||||
title = ""
|
||||
|
||||
|
|
|
|||
|
|
@ -352,8 +352,7 @@ def _unset_modifier_bits(
|
|||
"""
|
||||
if machinery.IS_QT5:
|
||||
return cast(_ModifierType, modifiers & ~mask)
|
||||
return Qt.KeyboardModifier( # type: ignore[unreachable]
|
||||
modifiers.value & ~mask.value)
|
||||
return Qt.KeyboardModifier(modifiers.value & ~mask.value)
|
||||
|
||||
|
||||
@dataclasses.dataclass(frozen=True, order=True)
|
||||
|
|
|
|||
|
|
@ -295,7 +295,7 @@ class ModeManager(QObject):
|
|||
has_modifier = event.modifiers() not in [
|
||||
Qt.KeyboardModifier.NoModifier,
|
||||
Qt.KeyboardModifier.ShiftModifier,
|
||||
] # type: ignore[comparison-overlap]
|
||||
]
|
||||
is_non_alnum = has_modifier or not event.text().strip()
|
||||
|
||||
forward_unbound_keys = config.cache['input.forward_unbound_keys']
|
||||
|
|
|
|||
|
|
@ -580,7 +580,7 @@ class MainWindow(QWidget):
|
|||
refresh_window = self.isVisible()
|
||||
if hidden:
|
||||
modifiers = Qt.WindowType.CustomizeWindowHint | Qt.WindowType.NoDropShadowWindowHint
|
||||
window_flags |= modifiers # type: ignore[assignment]
|
||||
window_flags |= modifiers
|
||||
self.setWindowFlags(window_flags)
|
||||
|
||||
if utils.is_mac and hidden and not qtutils.version_check('6.3', compiled=False):
|
||||
|
|
|
|||
|
|
@ -276,7 +276,7 @@ class Command(misc.CommandLineEdit):
|
|||
'prefix deleted')
|
||||
elif e.key() == Qt.Key.Key_Return:
|
||||
e.ignore()
|
||||
elif e.key() == Qt.Key.Key_Insert and e.modifiers() == Qt.KeyboardModifier.ShiftModifier: # type: ignore[comparison-overlap]
|
||||
elif e.key() == Qt.Key.Key_Insert and e.modifiers() == Qt.KeyboardModifier.ShiftModifier:
|
||||
try:
|
||||
text = utils.get_clipboard(selection=True, fallback=True)
|
||||
except utils.ClipboardError:
|
||||
|
|
|
|||
|
|
@ -221,8 +221,8 @@ class TabbedBrowser(QWidget):
|
|||
self._tab_insert_idx_right = -1
|
||||
self.is_shutting_down = False
|
||||
self.widget.tabCloseRequested.connect(self.on_tab_close_requested)
|
||||
self.widget.new_tab_requested.connect( # type: ignore[arg-type,unused-ignore]
|
||||
self.tabopen)
|
||||
self.widget.new_tab_requested.connect(
|
||||
self.tabopen) # type: ignore[arg-type,unused-ignore]
|
||||
self.widget.currentChanged.connect(self._on_current_changed)
|
||||
self.cur_fullscreen_requested.connect(self.widget.tab_bar().maybe_hide)
|
||||
|
||||
|
|
|
|||
|
|
@ -276,12 +276,12 @@ class IPCServer(QObject):
|
|||
|
||||
socket.errorOccurred.connect(self.on_error)
|
||||
|
||||
if socket.error() not in [ # type: ignore[operator]
|
||||
if socket.error() not in [
|
||||
QLocalSocket.LocalSocketError.UnknownSocketError,
|
||||
QLocalSocket.LocalSocketError.PeerClosedError
|
||||
]:
|
||||
log.ipc.debug("We got an error immediately.")
|
||||
self.on_error(socket.error()) # type: ignore[operator]
|
||||
self.on_error(socket.error())
|
||||
socket.disconnected.connect(self.on_disconnected)
|
||||
if socket.state() == QLocalSocket.LocalSocketState.UnconnectedState:
|
||||
log.ipc.debug("Socket was disconnected immediately.")
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ class Environment(jinja2.Environment):
|
|||
url = QUrl('qute://resource')
|
||||
url.setPath('/' + path)
|
||||
urlutils.ensure_valid(url)
|
||||
urlstr = url.toString(QUrl.ComponentFormattingOption.FullyEncoded) # type: ignore[arg-type]
|
||||
urlstr = url.toString(QUrl.ComponentFormattingOption.FullyEncoded)
|
||||
return urlstr
|
||||
|
||||
def _data_url(self, path: str) -> str:
|
||||
|
|
|
|||
|
|
@ -548,7 +548,7 @@ def file_url(path: str) -> str:
|
|||
path: The absolute path to the local file
|
||||
"""
|
||||
url = QUrl.fromLocalFile(path)
|
||||
return url.toString(QUrl.ComponentFormattingOption.FullyEncoded) # type: ignore[arg-type]
|
||||
return url.toString(QUrl.ComponentFormattingOption.FullyEncoded)
|
||||
|
||||
|
||||
def data_url(mimetype: str, data: bytes) -> QUrl:
|
||||
|
|
@ -639,7 +639,7 @@ def parse_javascript_url(url: QUrl) -> str:
|
|||
raise Error("URL contains unexpected components: {}"
|
||||
.format(url.authority()))
|
||||
|
||||
urlstr = url.toString(QUrl.ComponentFormattingOption.FullyEncoded) # type: ignore[arg-type]
|
||||
urlstr = url.toString(QUrl.ComponentFormattingOption.FullyEncoded)
|
||||
urlstr = urllib.parse.unquote(urlstr)
|
||||
|
||||
code = urlstr[len('javascript:'):]
|
||||
|
|
|
|||
Loading…
Reference in New Issue