From 91672cc8229d6b592e7de4e2df81c1505aa60678 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Fri, 16 Sep 2022 14:29:34 +0200 Subject: 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. --- qutebrowser/browser/browsertab.py | 6 ++---- 1 file 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 -- cgit v1.2.3-54-g00ecf