Python: update CI tests for pylint 2.10 and 2.11
cover Python: update CI tests for pylint 2.10 and 2.11
GitLab: https://gitlab.com/jsnow/qemu/-/commits/python-package-pylint-211
CI: https://gitlab.com/jsnow/qemu/-/pipelines/372122981
While debating the fix for 2.10, 2.11 released and added new warnings to suppress.
This version includes everything needed to get the Gitlab CI green again.
John Snow (2):
python: Update for pylint 2.10
python: pylint 2.11 support
python/qemu/machine/machine.py | 7 ++++++- python/setup.cfg | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-)
Signature · 1 line
2.31.1
PATCH 2/2 python: pylint 2.11 support
We're not ready to enforce f-strings everywhere, so just silence this new warning.
--- python/setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
python/setup.cfg +1 -1
@@ -87,7 +87,7 @@ ignore_missing_imports = True # --enable=similarities". If you want to run only the classes checker, but have # no Warning level messages displayed, use "--disable=all --enable=classes # --disable=W". -disable= +disable=consider-using-f-string, [pylint.basic] # Good variable names which should always be accepted, separated by a comma.
Signature · 1 line
2.31.1
PATCH 1/2 python: Update for pylint 2.10
In reply to John SnowA 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
Use LC_CTYPE to determine an encoding to use for interpreting QEMU's terminal output. Note that Python states: "language code and encoding may be None if their values cannot be determined" -- use a platform default as a backup.
Notes: Passing encoding=None will generate a suppressed warning on Python 3.10+ that 'None' should not be passed as the encoding argument. This behavior may be deprecated in the future and the default switched to be a ubiquitous UTF-8. Opting in to the locale default will be done by passing the encoding 'locale', but that isn't available in 3.6 through 3.9. Presumably this warning will be unsuppressed some time prior to the actual switch and we can re-investigate these issues at that time if necessary.
--- python/qemu/machine/machine.py | 7 ++++++- python/setup.cfg | 1 + 2 files changed, 7 insertions(+), 1 deletion(-)
python/qemu/machine/machine.py +6 -1
@@ -19,6 +19,7 @@ import errno from itertools import chain +import locale import logging import os import shutil
@@ -290,8 +291,12 @@ def get_pid(self) -> Optional[int]: return self._subp.pid def _load_io_log(self) -> None: + # Assume that the output encoding of QEMU's terminal output is + # defined by our locale. If indeterminate, allow open() to fall + # back to the platform default. + _, encoding = locale.getlocale() 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=encoding) as iolog: self._iolog = iolog.read() @property
python/setup.cfg +1 -0
@@ -104,6 +104,7 @@ good-names=i, [pylint.similarities] # Ignore imports when computing similarities. ignore-imports=yes +ignore-signatures=yes # Minimum lines number of a similarity. # TODO: Remove after we opt in to Pylint 2.8.3. See commit msg.
Signature · 1 line
2.31.1
Re: [PATCH 1/2] python: Update for pylint 2.10
Quoted 10 lines · John Snow
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/#motivationUse
LC_CTYPEto determine an encoding to use for interpreting QEMU's terminal output. Note that Python states: "language code and encoding may be None if their values cannot be determined" -- use a platform default as a backup.
Quoted 8 lines
Notes: Passing encoding=None will generate a suppressed warning on Python 3.10+ that 'None' should not be passed as the encoding argument. This behavior may be deprecated in the future and the default switched to be a ubiquitous UTF-8. Opting in to the locale default will be done by passing the encoding 'locale', but that isn't available in 3.6 through 3.9. Presumably this warning will be unsuppressed some time prior to the actual switch and we can re-investigate these issues at that time if necessary.
So, in the very worst case this will trigger a warning that is currently suppressed. And that will happen only if we are in the unlikely situation where we have absolutely no information about the encoding being used by other parts of the system.
Sounds reasonable to me, so:
Quoted 48 lines
Signed-off-by John Snow <[email protected]>--- python/qemu/machine/machine.py | 7 ++++++- python/setup.cfg | 1 + 2 files changed, 7 insertions(+), 1 deletion(-)python/qemu/machine/machine.py +6
-1@@ -19,6 +19,7 @@ import errno from itertools import chain +import locale import logging import os import shutil@@ -290,8 +291,12 @@ def get_pid(self) -> Optional[int]: return self._subp.pid def _load_io_log(self) -> None: + # Assume that the output encoding of QEMU's terminal output is + # defined by our locale. If indeterminate, allow open() to fall + # back to the platform default. + _, encoding = locale.getlocale() 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=encoding) as iolog: self._iolog = iolog.read() @propertypython/setup.cfg +1
-0@@ -104,6 +104,7 @@ good-names=i, [pylint.similarities] # Ignore imports when computing similarities. ignore-imports=yes +ignore-signatures=yes # Minimum lines number of a similarity. # TODO: Remove after we opt in to Pylint 2.8.3. See commit msg.Signature · 1 line
2.31.1
Signature · 1 line
Eduardo
Re: [PATCH 2/2] python: pylint 2.11 support
In reply to John SnowQuoted 4 lines · John Snow
We're not ready to enforce f-strings everywhere, so just silence this new warning.
Signed-off-by John Snow <[email protected]>
Signature · 1 line
Eduardo
Re: [PATCH 2/2] python: pylint 2.11 support
In reply to John SnowQuoted 3 lines · John Snow
We're not ready to enforce f-strings everywhere, so just silence this new warning.
Oh, boy! We are good, thanks :)
Quoted 6 lines
Signed-off-by John Snow <[email protected]>--- python/setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Re: [PATCH 1/2] python: Update for pylint 2.10
In reply to John SnowQuoted 20 lines · John Snow
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/#motivationUse
LC_CTYPEto determine an encoding to use for interpreting QEMU's terminal output. Note that Python states: "language code and encoding may be None if their values cannot be determined" -- use a platform default as a backup.Notes: Passing encoding=None will generate a suppressed warning on Python 3.10+ that 'None' should not be passed as the encoding argument. This behavior may be deprecated in the future and the default switched to be a ubiquitous UTF-8. Opting in to the locale default will be done by passing the encoding 'locale', but that isn't available in 3.6 through 3.9. Presumably this warning will be unsuppressed some time prior to the actual switch and we can re-investigate these issues at that time if necessary.
Quoted 6 lines
Signed-off-by John Snow <[email protected]>--- python/qemu/machine/machine.py | 7 ++++++- python/setup.cfg | 1 + 2 files changed, 7 insertions(+), 1 deletion(-)
Quoted 8 lines · John Snow
GitLab: https://gitlab.com/jsnow/qemu/-/commits/python-package-pylint-211
CI: https://gitlab.com/jsnow/qemu/-/pipelines/372122981While debating the fix for 2.10, 2.11 released and added new warnings to suppress.
This version includes everything needed to get the Gitlab CI green again.
Quoted 9 lines
John Snow (2):
python: Update for pylint 2.10
python: pylint 2.11 supportpython/qemu/machine/machine.py | 7 ++++++- python/setup.cfg | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-)
Eduardo, Willian: Thank you very much!
I have staged this on my python branch:
https://gitlab.com/jsnow/qemu/-/commits/python
PR to follow as soon as the lights turn green.
--js