summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Bruhin <git@the-compiler.org>2016-11-05 22:11:52 +0100
committerFlorian Bruhin <git@the-compiler.org>2016-11-05 22:13:03 +0100
commita876f4a199412d8c87670ef6985d2a09d40f24bf (patch)
tree2611d28e2d73ad580122d11c17849c20308e6c4f
parent661945c61b469015b2f016ff8086a0d47391643c (diff)
downloadqutebrowser-a876f4a199412d8c87670ef6985d2a09d40f24bf.tar.gz
qutebrowser-a876f4a199412d8c87670ef6985d2a09d40f24bf.zip
Fix handling of typing.Union with newer Python 3.5 versions
-rw-r--r--qutebrowser/commands/command.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/qutebrowser/commands/command.py b/qutebrowser/commands/command.py
index 35ba2fbfe..c1f5f41ee 100644
--- a/qutebrowser/commands/command.py
+++ b/qutebrowser/commands/command.py
@@ -419,9 +419,16 @@ class Command:
if isinstance(typ, tuple):
raise TypeError("{}: Legacy tuple type annotation!".format(
self.name))
- elif issubclass(typ, typing.Union):
+ elif type(typ) is type(typing.Union): # flake8: disable=E721
# this is... slightly evil, I know
- types = list(typ.__union_params__)
+ # We also can't use isinstance here because typing.Union doesn't
+ # support that.
+ # pylint: disable=no-member,useless-suppression
+ try:
+ types = list(typ.__union_params__)
+ except AttributeError:
+ types = list(typ.__args__)
+ # pylint: enable=no-member,useless-suppression
if param.default is not inspect.Parameter.empty:
types.append(type(param.default))
choices = self.get_arg_info(param).choices