From: Markus Armbruster <armbru@redhat.com>
To: John Snow <jsnow@redhat.com>
Cc: "Markus Armbruster" <armbru@redhat.com>,
qemu-devel <qemu-devel@nongnu.org>,
"Peter Xu" <peterx@redhat.com>,
"Daniel P. Berrangé" <berrange@redhat.com>,
"Stefan Berger" <stefanb@linux.vnet.ibm.com>,
"Fabiano Rosas" <farosas@suse.de>,
"Hanna Reitz" <hreitz@redhat.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Zhao Liu" <zhao1.liu@intel.com>, "Kevin Wolf" <kwolf@redhat.com>,
"Ani Sinha" <anisinha@redhat.com>,
"Pierrick Bouvier" <pierrick.bouvier@oss.qualcomm.com>,
"Jiri Pirko" <jiri@resnulli.us>,
"Alex Williamson" <alex@shazbot.org>,
"Kashyap Chamarthy" <kchamart@redhat.com>,
"Peter Maydell" <peter.maydell@linaro.org>,
"Kostiantyn Kostiuk" <kkostiuk@redhat.com>,
"Stefan Hajnoczi" <stefanha@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@oss.qualcomm.com>,
"Michael Roth" <michael.roth@amd.com>,
"Mauro Carvalho Chehab" <mchehab+huawei@kernel.org>,
"Vladimir Sementsov-Ogievskiy" <vsementsov@yandex-team.ru>,
"Marc-André Lureau" <marcandre.lureau@redhat.com>,
Qemu-block <qemu-block@nongnu.org>,
"Cédric Le Goater" <clg@redhat.com>,
"Stefano Garzarella" <sgarzare@redhat.com>,
"Richard Henderson" <richard.henderson@linaro.org>,
"Michael S. Tsirkin" <mst@redhat.com>,
"Igor Mammedov" <imammedo@redhat.com>,
"Jason Wang" <jasowangio@gmail.com>,
"Alex Bennée" <alex.bennee@linaro.org>,
"Eric Blake" <eblake@redhat.com>
Subject: Re: [PATCH 09/14] qapi/parser: remove _insert_after_intro() helper
Date: Tue, 29 Sep 2026 17:08:20 +0200 [thread overview]
Message-ID: <87v77oumcb.fsf@pond.sub.org> (raw)
In-Reply-To: <CAFn=p-Z_uyj_JHyXfPqq-7QGqzsjrDj6=_ObBG4S5U62CQu03Q@mail.gmail.com> (John Snow's message of "Tue, 29 Sep 2026 10:19:45 -0400")
John Snow <jsnow@redhat.com> writes:
> On Tue, Sep 29, 2026, 9:09 AM Markus Armbruster <armbru@redhat.com> wrote:
>
>> John Snow <jsnow@redhat.com> writes:
>>
>> > I promised I'd remove this.
>> >
>> > Signed-off-by: John Snow <jsnow@redhat.com>
>> > ---
>> > scripts/qapi/parser.py | 49 ++++++------------------------------------
>> > 1 file changed, 7 insertions(+), 42 deletions(-)
>> >
>> > diff --git a/scripts/qapi/parser.py b/scripts/qapi/parser.py
>> > index c14bff2cbc3..5fc9c18c81d 100644
>> > --- a/scripts/qapi/parser.py
>> > +++ b/scripts/qapi/parser.py
>> > @@ -862,49 +862,15 @@ def _insert_near_kind(
>> > return True
>> > return False
>> >
>> > - def _insert_after_intro(
>> > - self,
>> > - section: 'QAPIDoc.Section',
>> > - ) -> None:
>> > - """
>> > - Insert a section immediately after the intro section.
>> > -
>> > - While we convert DETAILS sections to INTRO sections, all
>> > - contiguous INTRO/DETAILS sections at the start of a QAPIDoc
>> > - section list are treated as "the intro".
>> > -
>> > - Once INTRO conversion is complete, this helper will no longer be
>> > - needed and ``_insert_near_kind(QAPIDoc.Kind.INTRO, ...)`` will
>> > - be sufficient.
>> > - """
>> > - first = self.all_sections[0]
>> > - if first.text and first.kind == QAPIDoc.Kind.INTRO:
>> > - # First section is introduction and is non-empty: insert here.
>> > - # Rest assured all of this ugliness will very soon go away.
>> > - # Pinkie-swear.
>> > - self.all_sections.insert(1, section)
>> > - return
>> > -
>> > - index = 0
>> > - for index, ref_section in enumerate(self.all_sections):
>> > - if ref_section.kind.name in ("INTRO", "DETAILS"):
>> > - continue
>> > - break
>> > - else:
>> > - index += 1
>> > -
>> > - self.all_sections.insert(index, section)
>> > -
>> > def append_member_stub(self, stub: 'QAPIDoc.Section') -> None:
>> > -
>> > """
>> > Append a stub section after any Member sections.
>> > """
>> > if self._insert_near_kind(QAPIDoc.Kind.MEMBER, stub, True):
>> > return
>> >
>> > - # No MEMBER sections present. Insert after INTRO/DETAILS sections.
>> > - self._insert_after_intro(stub)
>> > + # No MEMBER sections present. Insert after INTRO section.
>> > + self._insert_near_kind(QAPIDoc.Kind.INTRO, stub, after=True)
>>
>> There can only be one INTRO section, and it must be first. So this must
>> be equivalent to
>>
>> self.all_sections.(1, stub)
>>
>> Correct?
>>
>> The argument for using the more complex ._insert_near_kind() is of
>> course symmetry with the other case. Okay.
>>
>
> Yep, largely symmetry and opting to not write new logic as much as I can
> get away with in this patch. There's a compelling reason for not wasting
> much time writing new, cleaner logic...
>
>
>> We have three ._insert_near_kind() calls:
>>
>> if self._insert_near_kind(QAPIDoc.Kind.MEMBER, stub, True):
>>
>> self._insert_near_kind(QAPIDoc.Kind.INTRO, stub, after=True)
>>
>> if any(self._insert_near_kind(kind, stub, after) for kind, after
>> in (
>> [...]
>> )):
>>
>> None of them omit the optional last argument. Two pass it positionally,
>> one as a keyword argument. Let's dumb this down to mandatory argument.
>>
>
> I'll do you one better, that entire method goes away by the end of this
> series and we don't have to worry about it.
>
> No sense putting lipstick on the pig enroute to the slaughterhouse.
I see.
Recommend to keep the new call similar to the existing one nearby
regardless, i.e. pass True, not after=True.
[...]
next prev parent reply other threads:[~2026-09-29 15:09 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-28 22:36 [PATCH 00/14] qapi: enforce section ordering John Snow
2026-09-28 22:36 ` [PATCH 01/14] qapi: rename "plain" sections to "details" John Snow
2026-09-29 11:49 ` Markus Armbruster
2026-09-29 14:36 ` John Snow
2026-09-28 22:36 ` [PATCH 02/14] docs/qapi-code-gen: expand each section's syntax into a mini-section John Snow
2026-09-28 22:36 ` [PATCH 03/14] qapi: re-order QAPI doc block sections John Snow
2026-09-29 12:10 ` Markus Armbruster
2026-09-29 14:32 ` John Snow
2026-09-28 22:36 ` [PATCH 04/14] qapi/parser: enforce doc block section ordering John Snow
2026-09-29 12:36 ` Markus Armbruster
2026-09-29 14:31 ` John Snow
2026-09-29 15:00 ` Markus Armbruster
2026-09-28 22:36 ` [PATCH 05/14] qapi: move 'details' sections to the bottom of doc blocks John Snow
2026-10-01 11:14 ` Markus Armbruster
2026-09-28 22:36 ` [PATCH 06/14] qapi/parser: enforce 'details' sections' relative position John Snow
2026-09-28 22:36 ` [PATCH 07/14] qapi: re-order 'since' sections to always be last John Snow
2026-09-28 22:36 ` [PATCH 08/14] qapi/parser: enforce strict positioning for "Since:" section John Snow
2026-09-29 12:53 ` Markus Armbruster
2026-09-29 14:25 ` John Snow
2026-09-29 15:04 ` Markus Armbruster
2026-09-28 22:36 ` [PATCH 09/14] qapi/parser: remove _insert_after_intro() helper John Snow
2026-09-29 13:09 ` Markus Armbruster
2026-09-29 14:19 ` John Snow
2026-09-29 15:08 ` Markus Armbruster [this message]
2026-09-28 22:36 ` [PATCH 10/14] qapi/parser: add _append() method John Snow
2026-09-29 13:28 ` Markus Armbruster
2026-09-29 14:14 ` John Snow
2026-09-29 15:09 ` Markus Armbruster
2026-09-28 22:36 ` [PATCH 11/14] qapi/parser: privatize "all_sections" field as "_sections" John Snow
2026-10-02 8:51 ` Markus Armbruster
2026-09-28 22:36 ` [PATCH 12/14] qapi/parser: add _active_section private member John Snow
2026-09-28 22:36 ` [PATCH 13/14] qapi/parser: add new _sections mapping John Snow
2026-10-02 7:24 ` Markus Armbruster
2026-09-28 22:36 ` [PATCH 14/14] qapi/parser: convert single-section properties to getter properties John Snow
2026-10-02 9:44 ` Markus Armbruster
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=87v77oumcb.fsf@pond.sub.org \
--to=armbru@redhat.com \
--cc=alex.bennee@linaro.org \
--cc=alex@shazbot.org \
--cc=anisinha@redhat.com \
--cc=berrange@redhat.com \
--cc=clg@redhat.com \
--cc=eblake@redhat.com \
--cc=farosas@suse.de \
--cc=hreitz@redhat.com \
--cc=imammedo@redhat.com \
--cc=jasowangio@gmail.com \
--cc=jiri@resnulli.us \
--cc=jsnow@redhat.com \
--cc=kchamart@redhat.com \
--cc=kkostiuk@redhat.com \
--cc=kwolf@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=mchehab+huawei@kernel.org \
--cc=michael.roth@amd.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=peterx@redhat.com \
--cc=philmd@oss.qualcomm.com \
--cc=pierrick.bouvier@oss.qualcomm.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=sgarzare@redhat.com \
--cc=stefanb@linux.vnet.ibm.com \
--cc=stefanha@redhat.com \
--cc=vsementsov@yandex-team.ru \
--cc=zhao1.liu@intel.com \
/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.