From 63766c1711548ed119d197be22740b4cd4e3f61a Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Sat, 10 Feb 2018 17:22:21 +0100 Subject: [PATCH] Fix typing.Union checks with Python 3.7 --- doc/changelog.asciidoc | 1 + qutebrowser/commands/command.py | 4 +--- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/doc/changelog.asciidoc b/doc/changelog.asciidoc index 1f25fb8bf..d3755d4fc 100644 --- a/doc/changelog.asciidoc +++ b/doc/changelog.asciidoc @@ -76,6 +76,7 @@ Fixed - QtWebEngine: Qt download objects are now cleaned up properly when a download is removed. - Suspended pages now should always load the correct page when being un-suspended. +- Compatibility with Python 3.7 Removed ~~~~~~~ diff --git a/qutebrowser/commands/command.py b/qutebrowser/commands/command.py index fd3fcf20a..02fb72128 100644 --- a/qutebrowser/commands/command.py +++ b/qutebrowser/commands/command.py @@ -394,10 +394,8 @@ class Command: if isinstance(typ, tuple): raise TypeError("{}: Legacy tuple type annotation!".format( self.name)) - elif type(typ) is type(typing.Union): # noqa: E721 + elif getattr(typ, '__origin__', None) is typing.Union: # this is... slightly evil, I know - # We also can't use isinstance here because typing.Union doesn't - # support that. # pylint: disable=no-member,useless-suppression try: types = list(typ.__args__)