[PATCH 1/1] Fix a trivial flake8 warning

Remove an unused '_' in file Signed-off-by: jshen28 <yshxxsjt715@163.com> --- tools/virt-qemu-qmp-proxy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/virt-qemu-qmp-proxy b/tools/virt-qemu-qmp-proxy index dfbaa1ff0c..2d9dd6495d 100755 --- a/tools/virt-qemu-qmp-proxy +++ b/tools/virt-qemu-qmp-proxy @@ -335,7 +335,7 @@ def main(): sock.bind(args.sockpath) sock.listen(1) - _ = QMPProxy(conn, dom, sock, args.verbose) + QMPProxy(conn, dom, sock, args.verbose) while True: libvirt.virEventRunDefaultImpl() -- 2.17.1

On Wed, Feb 08, 2023 at 09:58:29PM +0800, jshen28 wrote:
Remove an unused '_' in file
What flake warning are you trying to fix, could you elaborate? When I run flake8 on that file I only get: tools/virt-qemu-qmp-proxy:233:80: E501 line too long (86 > 79 characters) I have flake8-6.0.0: 6.0.0 (mccabe: 0.7.0, pycodestyle: 2.10.0, pyflakes: 3.0.1) CPython 3.10.10 on Linux
Signed-off-by: jshen28 <yshxxsjt715@163.com> --- tools/virt-qemu-qmp-proxy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/virt-qemu-qmp-proxy b/tools/virt-qemu-qmp-proxy index dfbaa1ff0c..2d9dd6495d 100755 --- a/tools/virt-qemu-qmp-proxy +++ b/tools/virt-qemu-qmp-proxy @@ -335,7 +335,7 @@ def main(): sock.bind(args.sockpath) sock.listen(1)
- _ = QMPProxy(conn, dom, sock, args.verbose) + QMPProxy(conn, dom, sock, args.verbose)
I don't think you can do that because the object could be garbage collected, but I'm not sure how much havoc would that cause...
while True: libvirt.virEventRunDefaultImpl() -- 2.17.1

On Thu, Feb 09, 2023 at 10:00:27AM +0100, Martin Kletzander wrote: ...
diff --git a/tools/virt-qemu-qmp-proxy b/tools/virt-qemu-qmp-proxy index dfbaa1ff0c..2d9dd6495d 100755 --- a/tools/virt-qemu-qmp-proxy +++ b/tools/virt-qemu-qmp-proxy @@ -335,7 +335,7 @@ def main(): sock.bind(args.sockpath) sock.listen(1)
- _ = QMPProxy(conn, dom, sock, args.verbose) + QMPProxy(conn, dom, sock, args.verbose)
I don't think you can do that because the object could be garbage collected, but I'm not sure how much havoc would that cause...
Would it? Not advocating to accept the patch, but looking at the object it passes a reference to itself to qemuMonitorEventRegister() so as long as the monitor callback map exists the object should not be garbage collected. However the usage of _ in this case is IMO quite unfortunate in that it's simply there to really make sure Python holds one more explicit reference to the object. In cases like these Python's context managers are used instead. Erik

On Thu, Feb 09, 2023 at 12:39:04PM +0100, Erik Skultety wrote:
On Thu, Feb 09, 2023 at 10:00:27AM +0100, Martin Kletzander wrote: ...
diff --git a/tools/virt-qemu-qmp-proxy b/tools/virt-qemu-qmp-proxy index dfbaa1ff0c..2d9dd6495d 100755 --- a/tools/virt-qemu-qmp-proxy +++ b/tools/virt-qemu-qmp-proxy @@ -335,7 +335,7 @@ def main(): sock.bind(args.sockpath) sock.listen(1)
- _ = QMPProxy(conn, dom, sock, args.verbose) + QMPProxy(conn, dom, sock, args.verbose)
I don't think you can do that because the object could be garbage collected, but I'm not sure how much havoc would that cause...
Would it? Not advocating to accept the patch, but looking at the object it passes a reference to itself to qemuMonitorEventRegister() so as long as the monitor callback map exists the object should not be garbage collected. However the usage of _ in this case is IMO quite unfortunate in that it's simply there to really make sure Python holds one more explicit reference to the object. In cases like these Python's context managers are used instead.
Yep, using a context manager pattern there would have been more sane. With regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|

At 2023-02-09 19:43:03, "Daniel P. Berrangé" <berrange@redhat.com> wrote:
On Thu, Feb 09, 2023 at 12:39:04PM +0100, Erik Skultety wrote:
On Thu, Feb 09, 2023 at 10:00:27AM +0100, Martin Kletzander wrote: ...
diff --git a/tools/virt-qemu-qmp-proxy b/tools/virt-qemu-qmp-proxy index dfbaa1ff0c..2d9dd6495d 100755 --- a/tools/virt-qemu-qmp-proxy +++ b/tools/virt-qemu-qmp-proxy @@ -335,7 +335,7 @@ def main(): sock.bind(args.sockpath) sock.listen(1)
- _ = QMPProxy(conn, dom, sock, args.verbose) + QMPProxy(conn, dom, sock, args.verbose)
I don't think you can do that because the object could be garbage collected, but I'm not sure how much havoc would that cause...
Would it? Not advocating to accept the patch, but looking at the object it passes a reference to itself to qemuMonitorEventRegister() so as long as the monitor callback map exists the object should not be garbage collected. However the usage of _ in this case is IMO quite unfortunate in that it's simply there to really make sure Python holds one more explicit reference to the object. In cases like these Python's context managers are used instead.
Yep, using a context manager pattern there would have been more sane.
With regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Thank you for reply. The warning I am seeing is 208/279 libvirt:syntax-check / flake8 FAIL 1.53s (exit status 2) --- command --- 13:12:22 /usr/bin/make -C /home/sjt/src/c/libvirt/build/build-aux sc_flake8 --- stdout --- make: Entering directory '/home/sjt/src/c/libvirt/build/build-aux' /home/sjt/src/c/libvirt/tools/virt-qemu-qmp-proxy:338:5: F841 local variable '_' is assigned to but never used _ = QMPProxy(conn, dom, sock, args.verbose) the flake8 version is pretty old (3.5.0 (mccabe: 0.6.1, pycodestyle: 2.3.1, pyflakes: 1.6.0) CPython 3.6.9 on Linux)
participants (5)
-
Daniel P. Berrangé
-
Erik Skultety
-
jshen28
-
Martin Kletzander
-
Norman