All of lore.kernel.org
 help / color / mirror / Atom feed
From: John Snow <jsnow@redhat.com>
To: Max Reitz <mreitz@redhat.com>, qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
	ehabkost@redhat.com, qemu-block@nongnu.org, philmd@redhat.com,
	armbru@redhat.com
Subject: Re: [PATCH v8 07/11] iotests: limit line length to 79 chars
Date: Tue, 24 Mar 2020 13:09:45 -0400	[thread overview]
Message-ID: <bdff3fe8-fb51-51b1-f9b1-a111c2fcd04b@redhat.com> (raw)
In-Reply-To: <2f230c22-bd4b-ded5-27a9-1971efea0ec3@redhat.com>



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 <jsnow@redhat.com>
>>> ---
>>>  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



  reply	other threads:[~2020-03-24 17:10 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-17  0:40 [PATCH v8 00/11] iotests: use python logging John Snow
2020-03-17  0:40 ` [PATCH v8 01/11] iotests: do a light delinting John Snow
2020-03-24 13:56   ` Max Reitz
2020-03-17  0:40 ` [PATCH v8 02/11] iotests: don't use 'format' for drive_add John Snow
2020-03-17  0:40 ` [PATCH v8 03/11] iotests: ignore import warnings from pylint John Snow
2020-03-17 10:38   ` Philippe Mathieu-Daudé
2020-03-24 14:02   ` Max Reitz
2020-03-17  0:40 ` [PATCH v8 04/11] iotests: replace mutable list default args John Snow
2020-03-24 14:35   ` Max Reitz
2020-03-17  0:40 ` [PATCH v8 05/11] iotests: add pylintrc file John Snow
2020-03-24 14:47   ` Max Reitz
2020-03-17  0:41 ` [PATCH v8 06/11] iotests: drop Python 3.4 compatibility code John Snow
2020-03-24 14:54   ` Max Reitz
2020-03-24 16:57     ` John Snow
2020-03-17  0:41 ` [PATCH v8 07/11] iotests: limit line length to 79 chars John Snow
2020-03-17 10:36   ` Philippe Mathieu-Daudé
2020-03-17 13:48     ` John Snow
2020-03-24 15:02   ` Max Reitz
2020-03-24 15:12     ` Max Reitz
2020-03-24 17:09       ` John Snow [this message]
2020-03-24 17:38         ` Max Reitz
2020-03-17  0:41 ` [PATCH v8 08/11] iotests: add script_initialize John Snow
2020-03-17  0:41 ` [PATCH v8 09/11] iotest 258: use script_main John Snow
2020-03-17  0:41 ` [PATCH v8 10/11] iotests: Mark verify functions as private John Snow
2020-03-17  0:41 ` [PATCH v8 11/11] iotests: use python logging for iotests.log() John Snow
2020-03-24 16:14   ` Max Reitz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bdff3fe8-fb51-51b1-f9b1-a111c2fcd04b@redhat.com \
    --to=jsnow@redhat.com \
    --cc=armbru@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=philmd@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.