All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] iotests: Fix pylint warnings
@ 2021-08-24 15:35 Hanna Reitz
  2021-08-24 15:35 ` [PATCH 1/2] iotests: Fix unspecified-encoding " Hanna Reitz
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Hanna Reitz @ 2021-08-24 15:35 UTC (permalink / raw)
  To: qemu-block; +Cc: Kevin Wolf, Hanna Reitz, John Snow, qemu-devel

Hi,

I’ve updated my pylint to 2.10.2 and was greeted with some new warnings.
Some are fixed by John’s “Run iotest linters during Python CI” series
(https://lists.nongnu.org/archive/html/qemu-block/2021-07/msg00611.html),
but some are not (namely unspecified-encoding, use-list-literal, and
use-dict-literal).  This series cleans up that rest.


Hanna Reitz (2):
  iotests: Fix unspecified-encoding pylint warnings
  iotests: Fix use-{list,dict}-literal warnings

 tests/qemu-iotests/297        |  2 +-
 tests/qemu-iotests/iotests.py | 12 +++++++-----
 2 files changed, 8 insertions(+), 6 deletions(-)

-- 
2.31.1



^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/2] iotests: Fix unspecified-encoding pylint warnings
  2021-08-24 15:35 [PATCH 0/2] iotests: Fix pylint warnings Hanna Reitz
@ 2021-08-24 15:35 ` Hanna Reitz
  2021-08-24 15:47   ` Philippe Mathieu-Daudé
  2021-08-24 15:35 ` [PATCH 2/2] iotests: Fix use-{list,dict}-literal warnings Hanna Reitz
  2021-09-07  9:44 ` [PATCH 0/2] iotests: Fix pylint warnings Hanna Reitz
  2 siblings, 1 reply; 7+ messages in thread
From: Hanna Reitz @ 2021-08-24 15:35 UTC (permalink / raw)
  To: qemu-block; +Cc: Kevin Wolf, Hanna Reitz, John Snow, qemu-devel

As of recently, pylint complains when `open()` calls are missing an
`encoding=` specified.  Everything we have should be UTF-8 (and in fact,
everything should be UTF-8, period (exceptions apply)), so use that.

Signed-off-by: Hanna Reitz <hreitz@redhat.com>
---
 tests/qemu-iotests/297        | 2 +-
 tests/qemu-iotests/iotests.py | 8 +++++---
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/tests/qemu-iotests/297 b/tests/qemu-iotests/297
index 433b732336..0a49953d27 100755
--- a/tests/qemu-iotests/297
+++ b/tests/qemu-iotests/297
@@ -46,7 +46,7 @@ def is_python_file(filename):
     if filename.endswith('.py'):
         return True
 
-    with open(filename) as f:
+    with open(filename, encoding='utf-8') as f:
         try:
             first_line = f.readline()
             return re.match('^#!.*python', first_line) is not None
diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
index 4c8971d946..c05c16494b 100644
--- a/tests/qemu-iotests/iotests.py
+++ b/tests/qemu-iotests/iotests.py
@@ -610,7 +610,7 @@ def _post_shutdown(self) -> None:
             return
         valgrind_filename =  f"{test_dir}/{self._popen.pid}.valgrind"
         if self.exitcode() == 99:
-            with open(valgrind_filename) as f:
+            with open(valgrind_filename, encoding='utf-8') as f:
                 print(f.read())
         else:
             os.remove(valgrind_filename)
@@ -1120,7 +1120,8 @@ def notrun(reason):
     # Each test in qemu-iotests has a number ("seq")
     seq = os.path.basename(sys.argv[0])
 
-    with open('%s/%s.notrun' % (output_dir, seq), 'w') as outfile:
+    with open('%s/%s.notrun' % (output_dir, seq), 'w', encoding='utf-8') \
+            as outfile:
         outfile.write(reason + '\n')
     logger.warning("%s not run: %s", seq, reason)
     sys.exit(0)
@@ -1134,7 +1135,8 @@ def case_notrun(reason):
     # Each test in qemu-iotests has a number ("seq")
     seq = os.path.basename(sys.argv[0])
 
-    with open('%s/%s.casenotrun' % (output_dir, seq), 'a') as outfile:
+    with open('%s/%s.casenotrun' % (output_dir, seq), 'a', encoding='utf-8') \
+            as outfile:
         outfile.write('    [case not run] ' + reason + '\n')
 
 def _verify_image_format(supported_fmts: Sequence[str] = (),
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/2] iotests: Fix use-{list,dict}-literal warnings
  2021-08-24 15:35 [PATCH 0/2] iotests: Fix pylint warnings Hanna Reitz
  2021-08-24 15:35 ` [PATCH 1/2] iotests: Fix unspecified-encoding " Hanna Reitz
@ 2021-08-24 15:35 ` Hanna Reitz
  2021-09-02 10:13   ` Vladimir Sementsov-Ogievskiy
  2021-09-07  9:44 ` [PATCH 0/2] iotests: Fix pylint warnings Hanna Reitz
  2 siblings, 1 reply; 7+ messages in thread
From: Hanna Reitz @ 2021-08-24 15:35 UTC (permalink / raw)
  To: qemu-block; +Cc: Kevin Wolf, Hanna Reitz, John Snow, qemu-devel

pylint proposes using `[]` instead of `list()` and `{}` instead of
`dict()`, because it is faster.  That seems simple enough, so heed its
advice.

Signed-off-by: Hanna Reitz <hreitz@redhat.com>
---
 tests/qemu-iotests/iotests.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
index c05c16494b..8b44e6c437 100644
--- a/tests/qemu-iotests/iotests.py
+++ b/tests/qemu-iotests/iotests.py
@@ -702,7 +702,7 @@ def hmp_qemu_io(self, drive: str, cmd: str,
 
     def flatten_qmp_object(self, obj, output=None, basestr=''):
         if output is None:
-            output = dict()
+            output = {}
         if isinstance(obj, list):
             for i, item in enumerate(obj):
                 self.flatten_qmp_object(item, output, basestr + str(i) + '.')
@@ -715,7 +715,7 @@ def flatten_qmp_object(self, obj, output=None, basestr=''):
 
     def qmp_to_opts(self, obj):
         obj = self.flatten_qmp_object(obj)
-        output_list = list()
+        output_list = []
         for key in obj:
             output_list += [key + '=' + obj[key]]
         return ','.join(output_list)
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] iotests: Fix unspecified-encoding pylint warnings
  2021-08-24 15:35 ` [PATCH 1/2] iotests: Fix unspecified-encoding " Hanna Reitz
@ 2021-08-24 15:47   ` Philippe Mathieu-Daudé
  2021-09-15  0:50     ` John Snow
  0 siblings, 1 reply; 7+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-08-24 15:47 UTC (permalink / raw)
  To: Hanna Reitz, qemu-block; +Cc: Kevin Wolf, John Snow, qemu-devel

On 8/24/21 5:35 PM, Hanna Reitz wrote:
> As of recently, pylint complains when `open()` calls are missing an
> `encoding=` specified.  Everything we have should be UTF-8 (and in fact,
> everything should be UTF-8, period (exceptions apply)), so use that.
> 
> Signed-off-by: Hanna Reitz <hreitz@redhat.com>
> ---
>  tests/qemu-iotests/297        | 2 +-
>  tests/qemu-iotests/iotests.py | 8 +++++---
>  2 files changed, 6 insertions(+), 4 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/2] iotests: Fix use-{list,dict}-literal warnings
  2021-08-24 15:35 ` [PATCH 2/2] iotests: Fix use-{list,dict}-literal warnings Hanna Reitz
@ 2021-09-02 10:13   ` Vladimir Sementsov-Ogievskiy
  0 siblings, 0 replies; 7+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2021-09-02 10:13 UTC (permalink / raw)
  To: Hanna Reitz, qemu-block; +Cc: Kevin Wolf, John Snow, qemu-devel

24.08.2021 18:35, Hanna Reitz wrote:
> pylint proposes using `[]` instead of `list()` and `{}` instead of
> `dict()`, because it is faster.  That seems simple enough, so heed its
> advice.
> 
> Signed-off-by: Hanna Reitz<hreitz@redhat.com>

Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>

-- 
Best regards,
Vladimir


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 0/2] iotests: Fix pylint warnings
  2021-08-24 15:35 [PATCH 0/2] iotests: Fix pylint warnings Hanna Reitz
  2021-08-24 15:35 ` [PATCH 1/2] iotests: Fix unspecified-encoding " Hanna Reitz
  2021-08-24 15:35 ` [PATCH 2/2] iotests: Fix use-{list,dict}-literal warnings Hanna Reitz
@ 2021-09-07  9:44 ` Hanna Reitz
  2 siblings, 0 replies; 7+ messages in thread
From: Hanna Reitz @ 2021-09-07  9:44 UTC (permalink / raw)
  To: qemu-block; +Cc: Kevin Wolf, John Snow, qemu-devel

On 24.08.21 17:35, Hanna Reitz wrote:
> Hi,
>
> I’ve updated my pylint to 2.10.2 and was greeted with some new warnings.
> Some are fixed by John’s “Run iotest linters during Python CI” series
> (https://lists.nongnu.org/archive/html/qemu-block/2021-07/msg00611.html),
> but some are not (namely unspecified-encoding, use-list-literal, and
> use-dict-literal).  This series cleans up that rest.

Thanks for the reviews, applied to my block branch:

https://github.com/XanClic/qemu/commits/block

Hanna



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] iotests: Fix unspecified-encoding pylint warnings
  2021-08-24 15:47   ` Philippe Mathieu-Daudé
@ 2021-09-15  0:50     ` John Snow
  0 siblings, 0 replies; 7+ messages in thread
From: John Snow @ 2021-09-15  0:50 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Kevin Wolf, Hanna Reitz, qemu-devel, qemu-block

[-- Attachment #1: Type: text/plain, Size: 884 bytes --]

On Tue, Aug 24, 2021 at 11:47 AM Philippe Mathieu-Daudé <philmd@redhat.com>
wrote:

> On 8/24/21 5:35 PM, Hanna Reitz wrote:
> > As of recently, pylint complains when `open()` calls are missing an
> > `encoding=` specified.  Everything we have should be UTF-8 (and in fact,
> > everything should be UTF-8, period (exceptions apply)), so use that.
> >
> > Signed-off-by: Hanna Reitz <hreitz@redhat.com>
> > ---
> >  tests/qemu-iotests/297        | 2 +-
> >  tests/qemu-iotests/iotests.py | 8 +++++---
> >  2 files changed, 6 insertions(+), 4 deletions(-)
>
> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
>
>
I don't see this upstream just yet, so ...

Reviewed-by: John Snow <jsnow@redhat.com>

I'll get around to revisiting my "run the iotest linters on Python CI"
thing soon which will flush out anything else that might still be missing.

--js

[-- Attachment #2: Type: text/html, Size: 1521 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-09-15  0:52 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-24 15:35 [PATCH 0/2] iotests: Fix pylint warnings Hanna Reitz
2021-08-24 15:35 ` [PATCH 1/2] iotests: Fix unspecified-encoding " Hanna Reitz
2021-08-24 15:47   ` Philippe Mathieu-Daudé
2021-09-15  0:50     ` John Snow
2021-08-24 15:35 ` [PATCH 2/2] iotests: Fix use-{list,dict}-literal warnings Hanna Reitz
2021-09-02 10:13   ` Vladimir Sementsov-Ogievskiy
2021-09-07  9:44 ` [PATCH 0/2] iotests: Fix pylint warnings Hanna Reitz

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.