From 169a81880ad9f933026792842b623cbfbe8cb12c Mon Sep 17 00:00:00 2001 From: toofar Date: Mon, 25 Mar 2024 16:19:38 +1300 Subject: fix UndoEntry type hints probably, as mypy isn't passing on this branch anyhow. Also the whole tabbedbrowser class looks pretty lightly type hinted. --- qutebrowser/mainwindow/tabbedbrowser.py | 8 +++++--- qutebrowser/mainwindow/treetabbedbrowser.py | 6 +++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/qutebrowser/mainwindow/tabbedbrowser.py b/qutebrowser/mainwindow/tabbedbrowser.py index b006ef892..a635d803e 100644 --- a/qutebrowser/mainwindow/tabbedbrowser.py +++ b/qutebrowser/mainwindow/tabbedbrowser.py @@ -9,7 +9,7 @@ import functools import weakref import datetime import dataclasses -from typing import (Any, Deque, List, Mapping, +from typing import (Any, Deque, List, Mapping, Union, MutableMapping, MutableSequence, Optional, Tuple) from qutebrowser.qt.widgets import QSizePolicy, QWidget, QApplication @@ -38,14 +38,16 @@ class _UndoEntry: init=False, # WORKAROUND until py3.10 with kw_only: https://www.trueblade.com/blogs/news/python-3-10-new-dataclass-features ) - def restore_into_tab(self, tab: browsertab.AbstractTab): + def restore_into_tab(self, tab: browsertab.AbstractTab) -> None: """Set the url, history and state of `tab` from this undo entry.""" tab.history.private_api.deserialize(self.history) tab.set_pinned(self.pinned) tab.setFocus() @classmethod - def from_tab(cls, tab: browsertab.AbstractTab, idx: int): + def from_tab( + cls, tab: browsertab.AbstractTab, idx: int + ) -> Union["_UndoEntry", List["_UndoEntry"]]: """Generate an undo entry from `tab`.""" try: history_data = tab.history.private_api.serialize() diff --git a/qutebrowser/mainwindow/treetabbedbrowser.py b/qutebrowser/mainwindow/treetabbedbrowser.py index 3f2b6c7b1..ddbe91c97 100644 --- a/qutebrowser/mainwindow/treetabbedbrowser.py +++ b/qutebrowser/mainwindow/treetabbedbrowser.py @@ -6,7 +6,7 @@ import collections import dataclasses -from typing import List, Dict +from typing import List, Dict, Union from qutebrowser.qt.core import pyqtSlot, QUrl from qutebrowser.config import config @@ -25,7 +25,7 @@ class _TreeUndoEntry(_UndoEntry): children_node_uids: List[int] local_index: int # index of the tab relative to its siblings - def restore_into_tab(self, tab: browsertab.AbstractTab): + def restore_into_tab(self, tab: browsertab.AbstractTab) -> None: super().restore_into_tab(tab) root = tab.node.path[0] @@ -58,7 +58,7 @@ class _TreeUndoEntry(_UndoEntry): tab: browsertab.AbstractTab, idx: int, recursing: bool = False, - ): + ) -> Union["_TreeUndoEntry", List["_TreeUndoEntry"]]: """Make a TreeUndoEntry from a Node.""" node = tab.node url = node.value.url() -- cgit v1.2.3-54-g00ecf