qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 03/22] qapi/source: Remove line number from QAPISourceInfo in


From: John Snow
Subject: Re: [PATCH 03/22] qapi/source: Remove line number from QAPISourceInfo initializer
Date: Mon, 26 Apr 2021 19:14:34 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1

On 4/24/21 2:38 AM, Markus Armbruster wrote:
Mixing f-string and % interpolation.  I doubt we'd write it this way
from scratch.  I recommend to either stick to % for now (leave
conversion to f-strings for later), or conver the column formatting,
too, even though it's not related to the patch's purpose.

True. Two thoughts:

1. I don't like using % formatting because it behaves differently from .format() and f-strings. My overwhelming desire is to never use it for this reason.

Example: {foo} will call foo's __format__ method, whereas "%s" % foo will simply add str(foo). They are not always the same, not even for built-in Python objects.


2. Cleaning up the formatting here without cleaning it up everywhere is a great way to get the patch NACKed. You have in the past been fairly reluctant to "While we're here" cleanups, so I am trying to cut back on them.


This is why my habit for f-strings keeps trickling in: whenever I have to rewrite any interpolation, I reach for the one that behaves most idiomatically for Python 3. I am trying to balance that against churn that's not in the stated goals of the patch.

In this case: I'll clean the rest of the method to match; and add a note to the commit message that explains why. I will get around to removing all of the f-strings, but I want to hit the clean linter baseline first to help guide the testing for such a series. I regret the awkward transitional period.

--js




reply via email to

[Prev in Thread] Current Thread [Next in Thread]