Re: [PATCH v8 07/11] iotests: limit line length to 79 chars

2020-03-24 Thread Max Reitz
On 24.03.20 18:09, John Snow wrote:
> 
> 
> On 3/24/20 11:12 AM, Max Reitz wrote:
>> On 24.03.20 16:02, Max Reitz wrote:
>>> On 17.03.20 01:41, John Snow wrote:
 79 is the PEP8 recommendation. This recommendation works well for
 reading patch diffs in TUI email clients.
>>>
>>> Also for my very GUI-y diff program (kompare).
>>>
 Signed-off-by: John Snow 
 ---
  tests/qemu-iotests/iotests.py | 64 +++
  tests/qemu-iotests/pylintrc   |  6 +++-
  2 files changed, 47 insertions(+), 23 deletions(-)

 diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
 index 3d90fb157d..75fd697d77 100644
 --- a/tests/qemu-iotests/iotests.py
 +++ b/tests/qemu-iotests/iotests.py
>>>
>>> [...]
>>>
 @@ -529,11 +539,13 @@ def pause_drive(self, drive, event=None):
  self.pause_drive(drive, "write_aio")
  return
  self.qmp('human-monitor-command',
 - command_line='qemu-io %s "break %s bp_%s"' % (drive, 
 event, drive))
 + command_line='qemu-io %s "break %s bp_%s"'
 + % (drive, event, drive))
>>>
>>> Can we put this value in a variable instead?  I don’t like the %
>>> aligning with the parameter name instead of the string value.  (I also
>>> don’t like how there are no spaces around the assignment =, but around
>>> the %, even though the % binds more strongly.)
>>>
  
> 
> I think I had another patch somewhere that added an HMP helper that
> fixes this issue for this particular instance.
> 
> I can send that separately as a follow-up. I think otherwise,
> unfortunately, "we" "decided" that this indent style is "best".
> 
> So I think that this patch is "correct".

Perhaps it’s the best if we assume that we had to do it this way, but
can’t we just do a

qemu_io_cmd = f'qemu-io {drive} "break {event} bp_{drive}"'
self.qmp('human-monitor-command', command_line=qemu_io_cmd)

?

(Or maybe an f-string inline.  I was thinking of a separate variable
because I wasn’t aware that f-strings would be an option until I got to
later hunks of this patch...)

> (All of the other options for indent styles seemed to be worse visually,
> or actively go against PEP8. While PEP8 is not a bible, every conscious
> choice to disregard it generally means you will be fighting a CQA tool
> at some other point in time. I have therefore adopted a "When in Rome"
> policy to reduce friction wherever possible with pylint, flake8, mypy,
> pycharm, and so on.)
> 
> 
> ((I would prefer we begin to deprecate uses of % and begin using
> .format() and f-strings wherever possible to help alleviate this kind of
> syntax, too -- but I must insist that's for another series.))

Hm.  But you do change something to f-strings below, why not here?

Max



signature.asc
Description: OpenPGP digital signature


Re: [PATCH v8 07/11] iotests: limit line length to 79 chars

2020-03-24 Thread John Snow



On 3/24/20 11:12 AM, Max Reitz wrote:
> On 24.03.20 16:02, Max Reitz wrote:
>> On 17.03.20 01:41, John Snow wrote:
>>> 79 is the PEP8 recommendation. This recommendation works well for
>>> reading patch diffs in TUI email clients.
>>
>> Also for my very GUI-y diff program (kompare).
>>
>>> Signed-off-by: John Snow 
>>> ---
>>>  tests/qemu-iotests/iotests.py | 64 +++
>>>  tests/qemu-iotests/pylintrc   |  6 +++-
>>>  2 files changed, 47 insertions(+), 23 deletions(-)
>>>
>>> diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
>>> index 3d90fb157d..75fd697d77 100644
>>> --- a/tests/qemu-iotests/iotests.py
>>> +++ b/tests/qemu-iotests/iotests.py
>>
>> [...]
>>
>>> @@ -529,11 +539,13 @@ def pause_drive(self, drive, event=None):
>>>  self.pause_drive(drive, "write_aio")
>>>  return
>>>  self.qmp('human-monitor-command',
>>> - command_line='qemu-io %s "break %s bp_%s"' % (drive, 
>>> event, drive))
>>> + command_line='qemu-io %s "break %s bp_%s"'
>>> + % (drive, event, drive))
>>
>> Can we put this value in a variable instead?  I don’t like the %
>> aligning with the parameter name instead of the string value.  (I also
>> don’t like how there are no spaces around the assignment =, but around
>> the %, even though the % binds more strongly.)
>>
>>>  

I think I had another patch somewhere that added an HMP helper that
fixes this issue for this particular instance.

I can send that separately as a follow-up. I think otherwise,
unfortunately, "we" "decided" that this indent style is "best".

So I think that this patch is "correct".


(All of the other options for indent styles seemed to be worse visually,
or actively go against PEP8. While PEP8 is not a bible, every conscious
choice to disregard it generally means you will be fighting a CQA tool
at some other point in time. I have therefore adopted a "When in Rome"
policy to reduce friction wherever possible with pylint, flake8, mypy,
pycharm, and so on.)


((I would prefer we begin to deprecate uses of % and begin using
.format() and f-strings wherever possible to help alleviate this kind of
syntax, too -- but I must insist that's for another series.))


>>>  def resume_drive(self, drive):
>>>  self.qmp('human-monitor-command',
>>> - command_line='qemu-io %s "remove_break bp_%s"' % (drive, 
>>> drive))
>>> + command_line='qemu-io %s "remove_break bp_%s"'
>>> + % (drive, drive))
>>>  
>>>  def hmp_qemu_io(self, drive, cmd):
>>>  '''Write to a given drive using an HMP command'''
>>> @@ -793,16 +805,18 @@ def dictpath(self, d, path):
>>>  idx = int(idx)
>>>  
>>>  if not isinstance(d, dict) or component not in d:
>>> -self.fail('failed path traversal for "%s" in "%s"' % 
>>> (path, str(d)))
>>> +self.fail(f'failed path traversal for "{path}" in "{d}"')
>>
>> Do we require 3.6 so that f-strings are guaranteed to work?  (I thought
>> we didn’t.  I’d be happy to use them.)
> 
> Oh.  Of course we do.  It says so in this file that this whole series is
> about.
> 

Yup. I didn't like the idea of iotests using a newer version of python
than our build system, but my concern was not shared, so we get to use
f-strings for non-buildtime tools.

End of support for Python 3.5 will be 2020-09-13; so we'll get to use
f-strings everywhere else soon, too.

--js




Re: [PATCH v8 07/11] iotests: limit line length to 79 chars

2020-03-24 Thread Max Reitz
On 24.03.20 16:02, Max Reitz wrote:
> On 17.03.20 01:41, John Snow wrote:
>> 79 is the PEP8 recommendation. This recommendation works well for
>> reading patch diffs in TUI email clients.
> 
> Also for my very GUI-y diff program (kompare).
> 
>> Signed-off-by: John Snow 
>> ---
>>  tests/qemu-iotests/iotests.py | 64 +++
>>  tests/qemu-iotests/pylintrc   |  6 +++-
>>  2 files changed, 47 insertions(+), 23 deletions(-)
>>
>> diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
>> index 3d90fb157d..75fd697d77 100644
>> --- a/tests/qemu-iotests/iotests.py
>> +++ b/tests/qemu-iotests/iotests.py
> 
> [...]
> 
>> @@ -529,11 +539,13 @@ def pause_drive(self, drive, event=None):
>>  self.pause_drive(drive, "write_aio")
>>  return
>>  self.qmp('human-monitor-command',
>> - command_line='qemu-io %s "break %s bp_%s"' % (drive, 
>> event, drive))
>> + command_line='qemu-io %s "break %s bp_%s"'
>> + % (drive, event, drive))
> 
> Can we put this value in a variable instead?  I don’t like the %
> aligning with the parameter name instead of the string value.  (I also
> don’t like how there are no spaces around the assignment =, but around
> the %, even though the % binds more strongly.)
> 
>>  
>>  def resume_drive(self, drive):
>>  self.qmp('human-monitor-command',
>> - command_line='qemu-io %s "remove_break bp_%s"' % (drive, 
>> drive))
>> + command_line='qemu-io %s "remove_break bp_%s"'
>> + % (drive, drive))
>>  
>>  def hmp_qemu_io(self, drive, cmd):
>>  '''Write to a given drive using an HMP command'''
>> @@ -793,16 +805,18 @@ def dictpath(self, d, path):
>>  idx = int(idx)
>>  
>>  if not isinstance(d, dict) or component not in d:
>> -self.fail('failed path traversal for "%s" in "%s"' % (path, 
>> str(d)))
>> +self.fail(f'failed path traversal for "{path}" in "{d}"')
> 
> Do we require 3.6 so that f-strings are guaranteed to work?  (I thought
> we didn’t.  I’d be happy to use them.)

Oh.  Of course we do.  It says so in this file that this whole series is
about.

Max



signature.asc
Description: OpenPGP digital signature


Re: [PATCH v8 07/11] iotests: limit line length to 79 chars

2020-03-24 Thread Max Reitz
On 17.03.20 01:41, John Snow wrote:
> 79 is the PEP8 recommendation. This recommendation works well for
> reading patch diffs in TUI email clients.

Also for my very GUI-y diff program (kompare).

> Signed-off-by: John Snow 
> ---
>  tests/qemu-iotests/iotests.py | 64 +++
>  tests/qemu-iotests/pylintrc   |  6 +++-
>  2 files changed, 47 insertions(+), 23 deletions(-)
> 
> diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
> index 3d90fb157d..75fd697d77 100644
> --- a/tests/qemu-iotests/iotests.py
> +++ b/tests/qemu-iotests/iotests.py

[...]

> @@ -529,11 +539,13 @@ def pause_drive(self, drive, event=None):
>  self.pause_drive(drive, "write_aio")
>  return
>  self.qmp('human-monitor-command',
> - command_line='qemu-io %s "break %s bp_%s"' % (drive, event, 
> drive))
> + command_line='qemu-io %s "break %s bp_%s"'
> + % (drive, event, drive))

Can we put this value in a variable instead?  I don’t like the %
aligning with the parameter name instead of the string value.  (I also
don’t like how there are no spaces around the assignment =, but around
the %, even though the % binds more strongly.)

>  
>  def resume_drive(self, drive):
>  self.qmp('human-monitor-command',
> - command_line='qemu-io %s "remove_break bp_%s"' % (drive, 
> drive))
> + command_line='qemu-io %s "remove_break bp_%s"'
> + % (drive, drive))
>  
>  def hmp_qemu_io(self, drive, cmd):
>  '''Write to a given drive using an HMP command'''
> @@ -793,16 +805,18 @@ def dictpath(self, d, path):
>  idx = int(idx)
>  
>  if not isinstance(d, dict) or component not in d:
> -self.fail('failed path traversal for "%s" in "%s"' % (path, 
> str(d)))
> +self.fail(f'failed path traversal for "{path}" in "{d}"')

Do we require 3.6 so that f-strings are guaranteed to work?  (I thought
we didn’t.  I’d be happy to use them.)

Max



signature.asc
Description: OpenPGP digital signature


Re: [PATCH v8 07/11] iotests: limit line length to 79 chars

2020-03-17 Thread John Snow



On 3/17/20 6:36 AM, Philippe Mathieu-Daudé wrote:
> On 3/17/20 1:41 AM, John Snow wrote:
>> 79 is the PEP8 recommendation. This recommendation works well for
>> reading patch diffs in TUI email clients.
>>
>> Signed-off-by: John Snow 
>> ---
>>   tests/qemu-iotests/iotests.py | 64 +++
>>   tests/qemu-iotests/pylintrc   |  6 +++-
>>   2 files changed, 47 insertions(+), 23 deletions(-)
>>
>> diff --git a/tests/qemu-iotests/iotests.py
>> b/tests/qemu-iotests/iotests.py
>> index 3d90fb157d..75fd697d77 100644
>> --- a/tests/qemu-iotests/iotests.py
>> +++ b/tests/qemu-iotests/iotests.py
>> @@ -77,9 +77,11 @@
>>   def qemu_img(*args):
>>   '''Run qemu-img and return the exit code'''
>>   devnull = open('/dev/null', 'r+')
>> -    exitcode = subprocess.call(qemu_img_args + list(args),
>> stdin=devnull, stdout=devnull)
>> +    exitcode = subprocess.call(qemu_img_args + list(args),
>> +   stdin=devnull, stdout=devnull)
>>   if exitcode < 0:
>> -    sys.stderr.write('qemu-img received signal %i: %s\n' %
>> (-exitcode, ' '.join(qemu_img_args + list(args
>> +    sys.stderr.write('qemu-img received signal %i: %s\n'
>> + % (-exitcode, ' '.join(qemu_img_args +
>> list(args
>>   return exitcode
>>     def ordered_qmp(qmsg, conv_keys=True):
>> @@ -118,7 +120,8 @@ def qemu_img_verbose(*args):
>>   '''Run qemu-img without suppressing its output and return the
>> exit code'''
>>   exitcode = subprocess.call(qemu_img_args + list(args))
>>   if exitcode < 0:
>> -    sys.stderr.write('qemu-img received signal %i: %s\n' %
>> (-exitcode, ' '.join(qemu_img_args + list(args
>> +    sys.stderr.write('qemu-img received signal %i: %s\n'
>> + % (-exitcode, ' '.join(qemu_img_args +
>> list(args
>>   return exitcode
>>     def qemu_img_pipe(*args):
>> @@ -129,7 +132,8 @@ def qemu_img_pipe(*args):
>>   universal_newlines=True)
>>   exitcode = subp.wait()
>>   if exitcode < 0:
>> -    sys.stderr.write('qemu-img received signal %i: %s\n' %
>> (-exitcode, ' '.join(qemu_img_args + list(args
>> +    sys.stderr.write('qemu-img received signal %i: %s\n'
>> + % (-exitcode, ' '.join(qemu_img_args +
>> list(args
>>   return subp.communicate()[0]
>>     def qemu_img_log(*args):
>> @@ -159,7 +163,8 @@ def qemu_io(*args):
>>   universal_newlines=True)
>>   exitcode = subp.wait()
>>   if exitcode < 0:
>> -    sys.stderr.write('qemu-io received signal %i: %s\n' %
>> (-exitcode, ' '.join(args)))
>> +    sys.stderr.write('qemu-io received signal %i: %s\n'
>> + % (-exitcode, ' '.join(args)))
>>   return subp.communicate()[0]
>>     def qemu_io_log(*args):
>> @@ -281,10 +286,13 @@ def filter_test_dir(msg):
>>   def filter_win32(msg):
>>   return win32_re.sub("", msg)
>>   -qemu_io_re = re.compile(r"[0-9]* ops; [0-9\/:. sec]* \([0-9\/.inf]*
>> [EPTGMKiBbytes]*\/sec and [0-9\/.inf]* ops\/sec\)")
>> +qemu_io_re = re.compile(r"[0-9]* ops; [0-9\/:. sec]* "
>> +    r"\([0-9\/.inf]* [EPTGMKiBbytes]*\/sec "
>> +    r"and [0-9\/.inf]* ops\/sec\)")
>>   def filter_qemu_io(msg):
>>   msg = filter_win32(msg)
>> -    return qemu_io_re.sub("X ops; XX:XX:XX.X (XXX YYY/sec and XXX
>> ops/sec)", msg)
>> +    return qemu_io_re.sub("X ops; XX:XX:XX.X "
>> +  "(XXX YYY/sec and XXX ops/sec)", msg)
>>     chown_re = re.compile(r"chown [0-9]+:[0-9]+")
>>   def filter_chown(msg):
>> @@ -336,7 +344,9 @@ def filter_img_info(output, filename):
>>   line = line.replace(filename, 'TEST_IMG') \
>>  .replace(imgfmt, 'IMGFMT')
>>   line = re.sub('iters: [0-9]+', 'iters: XXX', line)
>> -    line = re.sub('uuid: [-a-f0-9]+', 'uuid:
>> ----', line)
>> +    line = re.sub('uuid: [-a-f0-9]+',
>> +  'uuid: ----',
>> +  line)
>>   line = re.sub('cid: [0-9]+', 'cid: XX', line)
>>   lines.append(line)
>>   return '\n'.join(lines)
>> @@ -529,11 +539,13 @@ def pause_drive(self, drive, event=None):
>>   self.pause_drive(drive, "write_aio")
>>   return
>>   self.qmp('human-monitor-command',
>> - command_line='qemu-io %s "break %s bp_%s"' % (drive,
>> event, drive))
>> + command_line='qemu-io %s "break %s bp_%s"'
>> + % (drive, event, drive))
>>     def resume_drive(self, drive):
>>   self.qmp('human-monitor-command',
>> - command_line='qemu-io %s "remove_break bp_%s"' %
>> (drive, drive))
>> + command_line='qemu-io %s "remove_break bp_%s"'
>> + % (drive, drive))
>>     def hmp_qemu_io(self, drive, 

Re: [PATCH v8 07/11] iotests: limit line length to 79 chars

2020-03-17 Thread Philippe Mathieu-Daudé

On 3/17/20 1:41 AM, John Snow wrote:

79 is the PEP8 recommendation. This recommendation works well for
reading patch diffs in TUI email clients.

Signed-off-by: John Snow 
---
  tests/qemu-iotests/iotests.py | 64 +++
  tests/qemu-iotests/pylintrc   |  6 +++-
  2 files changed, 47 insertions(+), 23 deletions(-)

diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
index 3d90fb157d..75fd697d77 100644
--- a/tests/qemu-iotests/iotests.py
+++ b/tests/qemu-iotests/iotests.py
@@ -77,9 +77,11 @@
  def qemu_img(*args):
  '''Run qemu-img and return the exit code'''
  devnull = open('/dev/null', 'r+')
-exitcode = subprocess.call(qemu_img_args + list(args), stdin=devnull, 
stdout=devnull)
+exitcode = subprocess.call(qemu_img_args + list(args),
+   stdin=devnull, stdout=devnull)
  if exitcode < 0:
-sys.stderr.write('qemu-img received signal %i: %s\n' % (-exitcode, ' 
'.join(qemu_img_args + list(args
+sys.stderr.write('qemu-img received signal %i: %s\n'
+ % (-exitcode, ' '.join(qemu_img_args + list(args
  return exitcode
  
  def ordered_qmp(qmsg, conv_keys=True):

@@ -118,7 +120,8 @@ def qemu_img_verbose(*args):
  '''Run qemu-img without suppressing its output and return the exit code'''
  exitcode = subprocess.call(qemu_img_args + list(args))
  if exitcode < 0:
-sys.stderr.write('qemu-img received signal %i: %s\n' % (-exitcode, ' 
'.join(qemu_img_args + list(args
+sys.stderr.write('qemu-img received signal %i: %s\n'
+ % (-exitcode, ' '.join(qemu_img_args + list(args
  return exitcode
  
  def qemu_img_pipe(*args):

@@ -129,7 +132,8 @@ def qemu_img_pipe(*args):
  universal_newlines=True)
  exitcode = subp.wait()
  if exitcode < 0:
-sys.stderr.write('qemu-img received signal %i: %s\n' % (-exitcode, ' 
'.join(qemu_img_args + list(args
+sys.stderr.write('qemu-img received signal %i: %s\n'
+ % (-exitcode, ' '.join(qemu_img_args + list(args
  return subp.communicate()[0]
  
  def qemu_img_log(*args):

@@ -159,7 +163,8 @@ def qemu_io(*args):
  universal_newlines=True)
  exitcode = subp.wait()
  if exitcode < 0:
-sys.stderr.write('qemu-io received signal %i: %s\n' % (-exitcode, ' 
'.join(args)))
+sys.stderr.write('qemu-io received signal %i: %s\n'
+ % (-exitcode, ' '.join(args)))
  return subp.communicate()[0]
  
  def qemu_io_log(*args):

@@ -281,10 +286,13 @@ def filter_test_dir(msg):
  def filter_win32(msg):
  return win32_re.sub("", msg)
  
-qemu_io_re = re.compile(r"[0-9]* ops; [0-9\/:. sec]* \([0-9\/.inf]* [EPTGMKiBbytes]*\/sec and [0-9\/.inf]* ops\/sec\)")

+qemu_io_re = re.compile(r"[0-9]* ops; [0-9\/:. sec]* "
+r"\([0-9\/.inf]* [EPTGMKiBbytes]*\/sec "
+r"and [0-9\/.inf]* ops\/sec\)")
  def filter_qemu_io(msg):
  msg = filter_win32(msg)
-return qemu_io_re.sub("X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)", 
msg)
+return qemu_io_re.sub("X ops; XX:XX:XX.X "
+  "(XXX YYY/sec and XXX ops/sec)", msg)
  
  chown_re = re.compile(r"chown [0-9]+:[0-9]+")

  def filter_chown(msg):
@@ -336,7 +344,9 @@ def filter_img_info(output, filename):
  line = line.replace(filename, 'TEST_IMG') \
 .replace(imgfmt, 'IMGFMT')
  line = re.sub('iters: [0-9]+', 'iters: XXX', line)
-line = re.sub('uuid: [-a-f0-9]+', 'uuid: 
----', line)
+line = re.sub('uuid: [-a-f0-9]+',
+  'uuid: ----',
+  line)
  line = re.sub('cid: [0-9]+', 'cid: XX', line)
  lines.append(line)
  return '\n'.join(lines)
@@ -529,11 +539,13 @@ def pause_drive(self, drive, event=None):
  self.pause_drive(drive, "write_aio")
  return
  self.qmp('human-monitor-command',
- command_line='qemu-io %s "break %s bp_%s"' % (drive, event, 
drive))
+ command_line='qemu-io %s "break %s bp_%s"'
+ % (drive, event, drive))
  
  def resume_drive(self, drive):

  self.qmp('human-monitor-command',
- command_line='qemu-io %s "remove_break bp_%s"' % (drive, 
drive))
+ command_line='qemu-io %s "remove_break bp_%s"'
+ % (drive, drive))
  
  def hmp_qemu_io(self, drive, cmd):

  '''Write to a given drive using an HMP command'''
@@ -793,16 +805,18 @@ def dictpath(self, d, path):
  idx = int(idx)
  
  if not isinstance(d, dict) or component not in d:

-self.fail('failed path traversal for "%s" in "%s"' % (path, 
str(d)))
+self.fail(f'failed path 

[PATCH v8 07/11] iotests: limit line length to 79 chars

2020-03-16 Thread John Snow
79 is the PEP8 recommendation. This recommendation works well for
reading patch diffs in TUI email clients.

Signed-off-by: John Snow 
---
 tests/qemu-iotests/iotests.py | 64 +++
 tests/qemu-iotests/pylintrc   |  6 +++-
 2 files changed, 47 insertions(+), 23 deletions(-)

diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
index 3d90fb157d..75fd697d77 100644
--- a/tests/qemu-iotests/iotests.py
+++ b/tests/qemu-iotests/iotests.py
@@ -77,9 +77,11 @@
 def qemu_img(*args):
 '''Run qemu-img and return the exit code'''
 devnull = open('/dev/null', 'r+')
-exitcode = subprocess.call(qemu_img_args + list(args), stdin=devnull, 
stdout=devnull)
+exitcode = subprocess.call(qemu_img_args + list(args),
+   stdin=devnull, stdout=devnull)
 if exitcode < 0:
-sys.stderr.write('qemu-img received signal %i: %s\n' % (-exitcode, ' 
'.join(qemu_img_args + list(args
+sys.stderr.write('qemu-img received signal %i: %s\n'
+ % (-exitcode, ' '.join(qemu_img_args + list(args
 return exitcode
 
 def ordered_qmp(qmsg, conv_keys=True):
@@ -118,7 +120,8 @@ def qemu_img_verbose(*args):
 '''Run qemu-img without suppressing its output and return the exit code'''
 exitcode = subprocess.call(qemu_img_args + list(args))
 if exitcode < 0:
-sys.stderr.write('qemu-img received signal %i: %s\n' % (-exitcode, ' 
'.join(qemu_img_args + list(args
+sys.stderr.write('qemu-img received signal %i: %s\n'
+ % (-exitcode, ' '.join(qemu_img_args + list(args
 return exitcode
 
 def qemu_img_pipe(*args):
@@ -129,7 +132,8 @@ def qemu_img_pipe(*args):
 universal_newlines=True)
 exitcode = subp.wait()
 if exitcode < 0:
-sys.stderr.write('qemu-img received signal %i: %s\n' % (-exitcode, ' 
'.join(qemu_img_args + list(args
+sys.stderr.write('qemu-img received signal %i: %s\n'
+ % (-exitcode, ' '.join(qemu_img_args + list(args
 return subp.communicate()[0]
 
 def qemu_img_log(*args):
@@ -159,7 +163,8 @@ def qemu_io(*args):
 universal_newlines=True)
 exitcode = subp.wait()
 if exitcode < 0:
-sys.stderr.write('qemu-io received signal %i: %s\n' % (-exitcode, ' 
'.join(args)))
+sys.stderr.write('qemu-io received signal %i: %s\n'
+ % (-exitcode, ' '.join(args)))
 return subp.communicate()[0]
 
 def qemu_io_log(*args):
@@ -281,10 +286,13 @@ def filter_test_dir(msg):
 def filter_win32(msg):
 return win32_re.sub("", msg)
 
-qemu_io_re = re.compile(r"[0-9]* ops; [0-9\/:. sec]* \([0-9\/.inf]* 
[EPTGMKiBbytes]*\/sec and [0-9\/.inf]* ops\/sec\)")
+qemu_io_re = re.compile(r"[0-9]* ops; [0-9\/:. sec]* "
+r"\([0-9\/.inf]* [EPTGMKiBbytes]*\/sec "
+r"and [0-9\/.inf]* ops\/sec\)")
 def filter_qemu_io(msg):
 msg = filter_win32(msg)
-return qemu_io_re.sub("X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)", 
msg)
+return qemu_io_re.sub("X ops; XX:XX:XX.X "
+  "(XXX YYY/sec and XXX ops/sec)", msg)
 
 chown_re = re.compile(r"chown [0-9]+:[0-9]+")
 def filter_chown(msg):
@@ -336,7 +344,9 @@ def filter_img_info(output, filename):
 line = line.replace(filename, 'TEST_IMG') \
.replace(imgfmt, 'IMGFMT')
 line = re.sub('iters: [0-9]+', 'iters: XXX', line)
-line = re.sub('uuid: [-a-f0-9]+', 'uuid: 
----', line)
+line = re.sub('uuid: [-a-f0-9]+',
+  'uuid: ----',
+  line)
 line = re.sub('cid: [0-9]+', 'cid: XX', line)
 lines.append(line)
 return '\n'.join(lines)
@@ -529,11 +539,13 @@ def pause_drive(self, drive, event=None):
 self.pause_drive(drive, "write_aio")
 return
 self.qmp('human-monitor-command',
- command_line='qemu-io %s "break %s bp_%s"' % (drive, event, 
drive))
+ command_line='qemu-io %s "break %s bp_%s"'
+ % (drive, event, drive))
 
 def resume_drive(self, drive):
 self.qmp('human-monitor-command',
- command_line='qemu-io %s "remove_break bp_%s"' % (drive, 
drive))
+ command_line='qemu-io %s "remove_break bp_%s"'
+ % (drive, drive))
 
 def hmp_qemu_io(self, drive, cmd):
 '''Write to a given drive using an HMP command'''
@@ -793,16 +805,18 @@ def dictpath(self, d, path):
 idx = int(idx)
 
 if not isinstance(d, dict) or component not in d:
-self.fail('failed path traversal for "%s" in "%s"' % (path, 
str(d)))
+self.fail(f'failed path traversal for "{path}" in "{d}"')
 d = d[component]
 
 if m: