summary refs log tree commit diff stats
path: root/python/qemu/qmp.py
diff options
context:
space:
mode:
authorJohn Snow <jsnow@redhat.com>2020-05-14 01:53:44 -0400
committerPhilippe Mathieu-Daudé <philmd@redhat.com>2020-05-31 18:25:31 +0200
commit1dda0404d8afeb0ed45fbeae85e380e1ff57da35 (patch)
treec1d0545fe4ac5d8de6c24b336f795c45e840ccdf /python/qemu/qmp.py
parent0add048fbd9992151e4c592977df9cff8558ca60 (diff)
downloadfocaccia-qemu-1dda0404d8afeb0ed45fbeae85e380e1ff57da35.tar.gz
focaccia-qemu-1dda0404d8afeb0ed45fbeae85e380e1ff57da35.zip
python/qemu: Adjust traceback typing
mypy considers it incorrect to use `bool` to statically return false,
because it will assume that it could conceivably return True, and gives
different analysis in that case. Use a None return to achieve the same
effect, but make mypy happy.

Note: Pylint considers function signatures as code that might trip the
duplicate-code checker. I'd rather not disable this as it does not
trigger often in practice, so I'm disabling it as a one-off and filed a
change request; see https://github.com/PyCQA/pylint/issues/3619

Signed-off-by: John Snow <jsnow@redhat.com>
Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20200514055403.18902-14-jsnow@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Diffstat (limited to 'python/qemu/qmp.py')
-rw-r--r--python/qemu/qmp.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/python/qemu/qmp.py b/python/qemu/qmp.py
index 73d49050ed..b91c9d5c1c 100644
--- a/python/qemu/qmp.py
+++ b/python/qemu/qmp.py
@@ -14,7 +14,9 @@ import logging
 from typing import (
     Optional,
     TextIO,
+    Type,
 )
+from types import TracebackType
 
 
 class QMPError(Exception):
@@ -146,10 +148,14 @@ class QEMUMonitorProtocol:
         # Implement context manager enter function.
         return self
 
-    def __exit__(self, exc_type, exc_value, exc_traceback):
+    def __exit__(self,
+                 # pylint: disable=duplicate-code
+                 # see https://github.com/PyCQA/pylint/issues/3619
+                 exc_type: Optional[Type[BaseException]],
+                 exc_val: Optional[BaseException],
+                 exc_tb: Optional[TracebackType]) -> None:
         # Implement context manager exit function.
         self.close()
-        return False
 
     def connect(self, negotiate=True):
         """