From aef633e76504f6f2f3be47a22b271ce6469c0d9d Mon Sep 17 00:00:00 2001 From: John Snow Date: Thu, 9 Feb 2023 19:31:41 -0500 Subject: python: support pylint 2.16 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Beraldo Leal Message-id: 20230210003147.1309376-2-jsnow@redhat.com Signed-off-by: John Snow --- python/qemu/qmp/protocol.py | 2 +- python/qemu/qmp/qmp_client.py | 2 +- python/qemu/utils/qemu_ga_client.py | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'python') diff --git a/python/qemu/qmp/protocol.py b/python/qemu/qmp/protocol.py index 6d3d739..22e6029 100644 --- a/python/qemu/qmp/protocol.py +++ b/python/qemu/qmp/protocol.py @@ -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 diff --git a/python/qemu/qmp/qmp_client.py b/python/qemu/qmp/qmp_client.py index b5772e7..9d73ae6 100644 --- a/python/qemu/qmp/qmp_client.py +++ b/python/qemu/qmp/qmp_client.py @@ -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] diff --git a/python/qemu/utils/qemu_ga_client.py b/python/qemu/utils/qemu_ga_client.py index 8c38a7a..d8411bb 100644 --- a/python/qemu/utils/qemu_ga_client.py +++ b/python/qemu/utils/qemu_ga_client.py @@ -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) -- cgit v1.1