]> git.proxmox.com Git - mirror_qemu.git/commitdiff
python: support pylint 2.16
authorJohn Snow <jsnow@redhat.com>
Fri, 10 Feb 2023 00:31:41 +0000 (19:31 -0500)
committerJohn Snow <jsnow@redhat.com>
Thu, 23 Feb 2023 04:35:03 +0000 (23:35 -0500)
Pylint 2.16 adds a few new checks that cause the optional check-tox CI
job to fail.

1. The superfluous-parens check seems to be a bit more aggressive,
2. broad-exception-raised is new; it discourages "raise Exception".

Fix these minor issues and turn the lights green.

Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Beraldo Leal <bleal@redhat.com>
Message-id: 20230210003147.1309376-2-jsnow@redhat.com
Signed-off-by: John Snow <jsnow@redhat.com>
python/qemu/qmp/protocol.py
python/qemu/qmp/qmp_client.py
python/qemu/utils/qemu_ga_client.py
tests/qemu-iotests/iotests.py
tests/qemu-iotests/tests/migrate-bitmaps-postcopy-test

index 6d3d739daa76d9b2d0a399da23f19875f0c39c3f..22e60298d2807c0e71e28b7bed278c8c6c595543 100644 (file)
@@ -207,7 +207,7 @@ class AsyncProtocol(Generic[T]):
     logger = logging.getLogger(__name__)
 
     # Maximum allowable size of read buffer
-    _limit = (64 * 1024)
+    _limit = 64 * 1024
 
     # -------------------------
     # Section: Public interface
index b5772e7f32b36790e8df99cf0f124716a9756f90..9d73ae6e7adab3a326945076ffb5ec15aab2d947 100644 (file)
@@ -198,7 +198,7 @@ class QMPClient(AsyncProtocol[Message], Events):
     logger = logging.getLogger(__name__)
 
     # Read buffer limit; 10MB like libvirt default
-    _limit = (10 * 1024 * 1024)
+    _limit = 10 * 1024 * 1024
 
     # Type alias for pending execute() result items
     _PendingT = Union[Message, ExecInterruptedError]
index 8c38a7ac9c0ee7ea96e5146d897ad7e5849dc829..d8411bb2d0b5010387512ad35ba2e28dbe9b6ba1 100644 (file)
@@ -155,7 +155,7 @@ class QemuGuestAgentClient:
 
     def fsfreeze(self, cmd: str) -> object:
         if cmd not in ['status', 'freeze', 'thaw']:
-            raise Exception('Invalid command: ' + cmd)
+            raise ValueError('Invalid command: ' + cmd)
         # Can be int (freeze, thaw) or GuestFsfreezeStatus (status)
         return getattr(self.qga, 'fsfreeze' + '_' + cmd)()
 
@@ -167,7 +167,7 @@ class QemuGuestAgentClient:
 
     def suspend(self, mode: str) -> None:
         if mode not in ['disk', 'ram', 'hybrid']:
-            raise Exception('Invalid mode: ' + mode)
+            raise ValueError('Invalid mode: ' + mode)
 
         try:
             getattr(self.qga, 'suspend' + '_' + mode)()
@@ -178,7 +178,7 @@ class QemuGuestAgentClient:
 
     def shutdown(self, mode: str = 'powerdown') -> None:
         if mode not in ['powerdown', 'halt', 'reboot']:
-            raise Exception('Invalid mode: ' + mode)
+            raise ValueError('Invalid mode: ' + mode)
 
         try:
             self.qga.shutdown(mode=mode)
index 94aeb3f3b2000d0e24bbfdd2cf5d719961a3c68f..3e82c634cfef9ccaeb624d5e804897e6cee0bf9d 100644 (file)
@@ -720,7 +720,7 @@ class Timeout:
         signal.setitimer(signal.ITIMER_REAL, 0)
         return False
     def timeout(self, signum, frame):
-        raise Exception(self.errmsg)
+        raise TimeoutError(self.errmsg)
 
 def file_pattern(name):
     return "{0}-{1}".format(os.getpid(), name)
@@ -804,7 +804,7 @@ def remote_filename(path):
     elif imgproto == 'ssh':
         return "ssh://%s@127.0.0.1:22%s" % (os.environ.get('USER'), path)
     else:
-        raise Exception("Protocol %s not supported" % (imgproto))
+        raise ValueError("Protocol %s not supported" % (imgproto))
 
 class VM(qtest.QEMUQtestMachine):
     '''A QEMU VM'''
index fc9c4b4ef411dc93e1abba0e58d2cbb0b122731d..dda55fad2840acf189b294952109493f27d57f6f 100755 (executable)
@@ -84,7 +84,7 @@ class TestDirtyBitmapPostcopyMigration(iotests.QMPTestCase):
                 e['vm'] = 'SRC'
             for e in self.vm_b_events:
                 e['vm'] = 'DST'
-            events = (self.vm_a_events + self.vm_b_events)
+            events = self.vm_a_events + self.vm_b_events
             events = [(e['timestamp']['seconds'],
                        e['timestamp']['microseconds'],
                        e['vm'],