From 80c5e920947cf0b8793ea51f7f05856c13d51229 Mon Sep 17 00:00:00 2001 From: Jan Verbeek Date: Thu, 10 Nov 2016 00:54:51 +0100 Subject: [PATCH 1/4] Fix Union tests for newer Python 3.5 versions --- tests/unit/utils/test_typing.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) 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) From 6d72bce4b6e8f6f594594651bc8bfa87fdb80a56 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Thu, 10 Nov 2016 22:41:41 +0100 Subject: [PATCH 2/4] Remove stub call for WebEngineCaret._on_mode_(entered|left) It doesn't really serve a purpose... --- qutebrowser/browser/webengine/webenginetab.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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() From 94e2a4dccc20686751de644b5604622b148ef00f Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Fri, 11 Nov 2016 07:04:01 +0100 Subject: [PATCH 3/4] Make sure the tab indicator color is always available --- qutebrowser/browser/commands.py | 3 +-- qutebrowser/mainwindow/tabwidget.py | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/qutebrowser/browser/commands.py b/qutebrowser/browser/commands.py index b4e3e5507..b326a1356 100644 --- a/qutebrowser/browser/commands.py +++ b/qutebrowser/browser/commands.py @@ -1041,8 +1041,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/mainwindow/tabwidget.py b/qutebrowser/mainwindow/tabwidget.py index 657a38dc3..3ad449b9c 100644 --- a/qutebrowser/mainwindow/tabwidget.py +++ b/qutebrowser/mainwindow/tabwidget.py @@ -91,6 +91,10 @@ class TabWidget(QTabWidget): bar.set_tab_data(idx, 'indicator-color', color) bar.update(bar.tabRect(idx)) + 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) @@ -329,6 +333,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. @@ -478,10 +489,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 From 2dd857d5802361ea60b76b73b60d8e096e906c8c Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Fri, 11 Nov 2016 07:40:21 +0100 Subject: [PATCH 4/4] Remove FakeTypingMeta.__subclasscheck__ --- qutebrowser/utils/typing.py | 4 ---- 1 file changed, 4 deletions(-) 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):