summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Bruhin <me@the-compiler.org>2022-09-16 14:29:34 +0200
committerFlorian Bruhin <me@the-compiler.org>2022-09-16 14:29:34 +0200
commit91672cc8229d6b592e7de4e2df81c1505aa60678 (patch)
treea4aa3e63c1de34403dfc5be4ce1c08f20655b071
parent8dd2bd5b54903cc7f7af9ae7e809c88d6193757c (diff)
downloadqutebrowser-91672cc8229d6b592e7de4e2df81c1505aa60678.tar.gz
qutebrowser-91672cc8229d6b592e7de4e2df81c1505aa60678.zip
mypy: Simplify handling in show_dialog
The problem here is that mypy (correctly) complains that self._dialog could be None again at the point that the lambda runs, which is a different variable scope. The assert can be dropped (in the show_dialog locals scope, mypy *knows* it's never None, as we just assigned it!). Follow-up to 1bbf75ae7dbbfa2568bd5fe50dc1d7d213377f4e.
-rw-r--r--qutebrowser/browser/browsertab.py6
1 files changed, 2 insertions, 4 deletions
diff --git a/qutebrowser/browser/browsertab.py b/qutebrowser/browser/browsertab.py
index 9c6c52e0e..3104c15b3 100644
--- a/qutebrowser/browser/browsertab.py
+++ b/qutebrowser/browser/browsertab.py
@@ -287,10 +287,8 @@ class AbstractPrinting(QObject):
def show_dialog(self) -> None:
"""Print with a QPrintDialog."""
- self._dialog = QPrintDialog(self._tab)
- assert self._dialog is not None
- not_none_dialog = self._dialog
- self._dialog.open(lambda: self.to_printer(not_none_dialog.printer()))
+ self._dialog = dialog = QPrintDialog(self._tab)
+ self._dialog.open(lambda: self.to_printer(dialog.printer()))
# Gets cleaned up in on_printing_finished