qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 1/1] python: Update for pylint 2.10


From: John Snow
Subject: [PATCH 1/1] python: Update for pylint 2.10
Date: Sat, 21 Aug 2021 15:04:51 -0400

A few new annoyances. Of note is the new warning for an unspecified
encoding when opening a text file, which actually does indicate a
potentially real problem; see
https://www.python.org/dev/peps/pep-0597/#motivation

I was under the impression that open would try to figure out the
encoding of a file for you -- apparently this is completely false. It
uses the platform's preferred encoding, whatever that may be.

What we ought to use here, I believe, is sys.stderr.encoding.

Signed-off-by: John Snow <jsnow@redhat.com>
---
 python/qemu/machine/machine.py | 6 ++++--
 python/setup.cfg               | 1 +
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/python/qemu/machine/machine.py b/python/qemu/machine/machine.py
index 971ed7e8c6..1f47fc5a2b 100644
--- a/python/qemu/machine/machine.py
+++ b/python/qemu/machine/machine.py
@@ -25,6 +25,7 @@
 import signal
 import socket
 import subprocess
+import sys
 import tempfile
 from types import TracebackType
 from typing import (
@@ -284,7 +285,8 @@ def get_pid(self) -> Optional[int]:
 
     def _load_io_log(self) -> None:
         if self._qemu_log_path is not None:
-            with open(self._qemu_log_path, "r") as iolog:
+            with open(self._qemu_log_path, "r",
+                      encoding=sys.stdout.encoding) as iolog:
                 self._iolog = iolog.read()
 
     @property
@@ -565,7 +567,7 @@ def _qmp(self) -> QEMUMonitorProtocol:
 
     @classmethod
     def _qmp_args(cls, _conv_keys: bool = True, **args: Any) -> Dict[str, Any]:
-        qmp_args = dict()
+        qmp_args = {}
         for key, value in args.items():
             if _conv_keys:
                 qmp_args[key.replace('_', '-')] = value
diff --git a/python/setup.cfg b/python/setup.cfg
index 14bab90288..f220419755 100644
--- a/python/setup.cfg
+++ b/python/setup.cfg
@@ -104,6 +104,7 @@ good-names=i,
 [pylint.similarities]
 # Ignore imports when computing similarities.
 ignore-imports=yes
+ignore-signatures=yes
 
 [isort]
 force_grid_wrap=4
-- 
2.31.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]