diff --git a/qutebrowser/browser/commands.py b/qutebrowser/browser/commands.py index aa0ad0a36..d9122f869 100644 --- a/qutebrowser/browser/commands.py +++ b/qutebrowser/browser/commands.py @@ -1091,8 +1091,7 @@ class CommandDispatcher: cmdutils.check_overflow(new_idx, 'int') self._tabbed_browser.setUpdatesEnabled(False) try: - color = self._tabbed_browser.tabBar().tab_data( - cur_idx, 'indicator-color') + color = self._tabbed_browser.tab_indicator_color(cur_idx) self._tabbed_browser.removeTab(cur_idx) self._tabbed_browser.insertTab(new_idx, tab, icon, label) self._set_current_index(new_idx) diff --git a/qutebrowser/browser/webengine/webenginetab.py b/qutebrowser/browser/webengine/webenginetab.py index 46921d455..c66f3fe2e 100644 --- a/qutebrowser/browser/webengine/webenginetab.py +++ b/qutebrowser/browser/webengine/webenginetab.py @@ -150,11 +150,11 @@ class WebEngineCaret(browsertab.AbstractCaret): @pyqtSlot(usertypes.KeyMode) def _on_mode_entered(self, mode): - log.stub() + pass @pyqtSlot(usertypes.KeyMode) def _on_mode_left(self): - log.stub() + pass def move_to_next_line(self, count=1): log.stub() diff --git a/qutebrowser/mainwindow/tabwidget.py b/qutebrowser/mainwindow/tabwidget.py index c12b88952..50ab0af92 100644 --- a/qutebrowser/mainwindow/tabwidget.py +++ b/qutebrowser/mainwindow/tabwidget.py @@ -109,6 +109,10 @@ class TabWidget(QTabWidget): bar.refresh() + def tab_indicator_color(self, idx): + """Get the tab indicator color for the given index.""" + return self.tabBar().tab_indicator_color(idx) + def set_page_title(self, idx, title): """Set the tab title user data.""" self.tabBar().set_tab_data(idx, 'page-title', title) @@ -361,6 +365,13 @@ class TabBar(QTabBar): data = {} return data[key] + def tab_indicator_color(self, idx): + """Get the tab indicator color for the given index.""" + try: + return self.tab_data(idx, 'indicator-color') + except KeyError: + return QColor() + def page_title(self, idx): """Get the tab title user data. @@ -529,10 +540,7 @@ class TabBar(QTabBar): tab.palette.setColor(QPalette.Window, bg_color) tab.palette.setColor(QPalette.WindowText, fg_color) - try: - indicator_color = self.tab_data(idx, 'indicator-color') - except KeyError: - indicator_color = QColor() + indicator_color = self.tab_indicator_color(idx) tab.palette.setColor(QPalette.Base, indicator_color) if tab.rect.right() < 0 or tab.rect.left() > self.width(): # Don't bother drawing a tab if the entire tab is outside of diff --git a/qutebrowser/utils/typing.py b/qutebrowser/utils/typing.py index ff73c25a0..dca42acd6 100644 --- a/qutebrowser/utils/typing.py +++ b/qutebrowser/utils/typing.py @@ -38,10 +38,6 @@ class FakeTypingMeta(type): **_kwds): pass - def __subclasscheck__(self, cls): - """We implement this for qutebrowser.commands.command to work.""" - return isinstance(cls, FakeTypingMeta) - class FakeUnionMeta(FakeTypingMeta): diff --git a/tests/unit/utils/test_typing.py b/tests/unit/utils/test_typing.py index 3beefb424..fc507299c 100644 --- a/tests/unit/utils/test_typing.py +++ b/tests/unit/utils/test_typing.py @@ -32,13 +32,23 @@ def pytyping(): class TestUnion: def test_python_subclass(self, pytyping): - assert issubclass(pytyping.Union[str, int], pytyping.Union) + assert (type(pytyping.Union[str, int]) is # flake8: disable=E721 + type(pytyping.Union)) def test_qute_subclass(self): - assert issubclass(typing.FakeUnion[str, int], typing.FakeUnion) + assert (type(typing.FakeUnion[str, int]) is # flake8: disable=E721 + type(typing.FakeUnion)) def test_python_params(self, pytyping): - assert pytyping.Union[str, int].__union_params__ == (str, int) + union = pytyping.Union[str, int] + try: + assert union.__union_params__ == (str, int) + except AttributeError: + assert union.__args__ == (str, int) def test_qute_params(self): - assert typing.FakeUnion[str, int].__union_params__ == (str, int) + union = typing.FakeUnion[str, int] + try: + assert union.__union_params__ == (str, int) + except AttributeError: + assert union.__args__ == (str, int)