From 80c5e920947cf0b8793ea51f7f05856c13d51229 Mon Sep 17 00:00:00 2001 From: Jan Verbeek Date: Thu, 10 Nov 2016 00:54:51 +0100 Subject: [PATCH 1/2] 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 2dd857d5802361ea60b76b73b60d8e096e906c8c Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Fri, 11 Nov 2016 07:40:21 +0100 Subject: [PATCH 2/2] 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):