diff options
author | Florian Bruhin <me@the-compiler.org> | 2019-10-15 18:59:57 +0200 |
---|---|---|
committer | Florian Bruhin <me@the-compiler.org> | 2019-10-15 18:59:57 +0200 |
commit | 576f9d8dcfd7e6dd791f1e6fdf2baa56b2cd8436 (patch) | |
tree | 30903d33d7e9802a71b4e19a14ec4fe54f17c949 /qutebrowser/commands | |
parent | fe2463c63bd06c1a2a0c0a9326b166908a42101f (diff) | |
download | qutebrowser-576f9d8dcfd7e6dd791f1e6fdf2baa56b2cd8436.tar.gz qutebrowser-576f9d8dcfd7e6dd791f1e6fdf2baa56b2cd8436.zip |
Make union check more readable
Diffstat (limited to 'qutebrowser/commands')
-rw-r--r-- | qutebrowser/commands/command.py | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/qutebrowser/commands/command.py b/qutebrowser/commands/command.py index a813bd123..a3417f346 100644 --- a/qutebrowser/commands/command.py +++ b/qutebrowser/commands/command.py @@ -406,11 +406,14 @@ class Command: raise TypeError("{}: Legacy tuple type annotation!".format( self.name)) - if getattr(typ, '__origin__', None) is typing.Union or ( - # Python 3.5.2 - # pylint: disable=no-member,useless-suppression - hasattr(typing, 'UnionMeta') and - isinstance(typ, typing.UnionMeta)): # type: ignore + if hasattr(typing, 'UnionMeta'): + # Python 3.5.2 + # pylint: disable=no-member,useless-suppression + is_union = isinstance(typ, typing.UnionMeta) # type: ignore + else: + is_union = getattr(typ, '__origin__', None) is typing.Union + + if is_union: # this is... slightly evil, I know try: types = list(typ.__args__) |