Skip to contentSkip to conversation

Update check-python-tox test for pylint 2.10

PATCH Superseded John Snow 1 participant 2 messages Aug 21, 2021

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

John Snow

author
#0 lore raw

cover Update check-python-tox test for pylint 2.10

The 'check-python-tox' CI test will probably start showing warnings without this. This can go into the next release, just ignore the CI warning until the tree opens.

John Snow (1):
python: Update for pylint 2.10

 python/qemu/machine/machine.py | 6 ++++--
 python/setup.cfg               | 1 +
 2 files changed, 5 insertions(+), 2 deletions(-)
Signature · 1 line
2.31.1
author
#1 lore raw

PATCH 1/1 python: Update for pylint 2.10

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.

---
 python/qemu/machine/machine.py | 6 ++++--
 python/setup.cfg               | 1 +
 2 files changed, 5 insertions(+), 2 deletions(-)
python/qemu/machine/machine.py +4 -2
index 971ed7e8c6..1f47fc5a2b 100644
@@ -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
python/setup.cfg +1 -0
index 14bab90288..f220419755 100644
@@ -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
Signature · 1 line
2.31.1