diff options
author | Florian Bruhin <me@the-compiler.org> | 2021-01-11 12:00:30 +0100 |
---|---|---|
committer | Florian Bruhin <me@the-compiler.org> | 2021-01-11 18:47:15 +0100 |
commit | c1758230200814e84055f3e2954cb69f0fddf5d8 (patch) | |
tree | b9123f2c04e3337084e0894c0bb17574b9704311 /qutebrowser/components | |
parent | 8760dc1b17dcf06f7253a9ce7ac7a15af0785492 (diff) | |
download | qutebrowser-c1758230200814e84055f3e2954cb69f0fddf5d8.tar.gz qutebrowser-c1758230200814e84055f3e2954cb69f0fddf5d8.zip |
Add objects.qapp to avoid needing to None-check
We know that QApplication.instance() will always be non-None for
practical purposes, but the stubs now (correctly) declare it as
Optional.
See https://github.com/stlehmann/PyQt5-stubs/pull/126
Diffstat (limited to 'qutebrowser/components')
-rw-r--r-- | qutebrowser/components/readlinecommands.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/qutebrowser/components/readlinecommands.py b/qutebrowser/components/readlinecommands.py index ea8f12edf..44772f10f 100644 --- a/qutebrowser/components/readlinecommands.py +++ b/qutebrowser/components/readlinecommands.py @@ -39,7 +39,11 @@ class _ReadlineBridge: def _widget(self) -> Optional[QLineEdit]: """Get the currently active QLineEdit.""" - w = QApplication.instance().focusWidget() + # FIXME add this to api.utils or so + qapp = QApplication.instance() + assert qapp is not None + w = qapp.focusWidget() + if isinstance(w, QLineEdit): return w else: |