diff options
author | Florian Bruhin <me@the-compiler.org> | 2020-11-20 12:13:32 +0100 |
---|---|---|
committer | Florian Bruhin <me@the-compiler.org> | 2020-11-20 12:20:19 +0100 |
commit | 0c29484bcb322e9d47e1cbab0be2f647aa274d96 (patch) | |
tree | 63bf5880cd5cd09aad25a3a566637b638a3529b4 | |
parent | 56fa5db62ac5f672f17503d4deab1e671d800a2c (diff) | |
download | qutebrowser-0c29484bcb322e9d47e1cbab0be2f647aa274d96.tar.gz qutebrowser-0c29484bcb322e9d47e1cbab0be2f647aa274d96.zip |
Fix metaclass conflict for VersionNumber
While inheriting from SupportsLessThan and QVersionNumber is correct for
mypy, it leads to "TypeError: metaclass conflict: the metaclass of a
derived class must be a (non-strict) subclass of the metaclasses of all
its bases" at runtime...
-rw-r--r-- | qutebrowser/utils/utils.py | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/qutebrowser/utils/utils.py b/qutebrowser/utils/utils.py index 1652567af..7684d9eca 100644 --- a/qutebrowser/utils/utils.py +++ b/qutebrowser/utils/utils.py @@ -73,7 +73,8 @@ try: except ImportError: if not TYPE_CHECKING: class Protocol: - pass + + """Empty stub at runtime.""" class SupportsLessThan(Protocol): @@ -83,9 +84,15 @@ class SupportsLessThan(Protocol): def __lt__(self, other: Any) -> bool: ... -class VersionNumber(SupportsLessThan, QVersionNumber): - """WORKAROUND for incorrect PyQt stubs.""" +if TYPE_CHECKING: + class VersionNumber(SupportsLessThan, QVersionNumber): + + """WORKAROUND for incorrect PyQt stubs.""" +else: + class VersionNumber: + + """We can't inherit from Protocol and QVersionNumber at runtime.""" class Unreachable(Exception): |