From: Markus Armbruster <armbru@redhat.com>
To: John Snow <jsnow@redhat.com>
Cc: qemu-devel@nongnu.org, "Joel Stanley" <joel@jms.id.au>,
"Yi Liu" <yi.l.liu@intel.com>,
"Alex Bennée" <alex.bennee@linaro.org>,
"Helge Deller" <deller@gmx.de>,
"Marcel Apfelbaum" <marcel.apfelbaum@gmail.com>,
"Andrew Jeffery" <andrew@codeconstruct.com.au>,
"Fabiano Rosas" <farosas@suse.de>,
"Alexander Bulekov" <alxndr@bu.edu>,
"Darren Kenny" <darren.kenny@oracle.com>,
"Leif Lindholm" <leif.lindholm@oss.qualcomm.com>,
"Cédric Le Goater" <clg@kaod.org>,
"Ed Maste" <emaste@freebsd.org>,
"Gerd Hoffmann" <kraxel@redhat.com>,
"Warner Losh" <imp@bsdimp.com>, "Kevin Wolf" <kwolf@redhat.com>,
"Tyrone Ting" <kfting@nuvoton.com>,
"Eric Blake" <eblake@redhat.com>,
"Palmer Dabbelt" <palmer@dabbelt.com>,
"Yoshinori Sato" <ysato@users.sourceforge.jp>,
"Troy Lee" <leetroy@gmail.com>,
"Halil Pasic" <pasic@linux.ibm.com>,
"Akihiko Odaki" <odaki@rsg.ci.i.u-tokyo.ac.jp>,
"Michael Roth" <michael.roth@amd.com>,
"Laurent Vivier" <laurent@vivier.eu>,
"Ani Sinha" <anisinha@redhat.com>,
"Weiwei Li" <liwei1518@gmail.com>,
"Eric Farman" <farman@linux.ibm.com>,
"Steven Lee" <steven_lee@aspeedtech.com>,
"Brian Cain" <brian.cain@oss.qualcomm.com>,
"Li-Wen Hsu" <lwhsu@freebsd.org>,
"Jamin Lin" <jamin_lin@aspeedtech.com>,
qemu-s390x@nongnu.org,
"Vladimir Sementsov-Ogievskiy" <vsementsov@yandex-team.ru>,
qemu-block@nongnu.org, "Bernhard Beschow" <shentey@gmail.com>,
"Clément Mathieu--Drif" <clement.mathieu--drif@eviden.com>,
"Maksim Davydov" <davydov-max@yandex-team.ru>,
"Niek Linnenbank" <nieklinnenbank@gmail.com>,
"Hervé Poussineau" <hpoussin@reactos.org>,
"Christian Borntraeger" <borntraeger@linux.ibm.com>,
"Paul Durrant" <paul@xen.org>,
"Manos Pitsidianakis" <manos.pitsidianakis@linaro.org>,
"Jagannathan Raman" <jag.raman@oracle.com>,
"Igor Mitsyanko" <i.mitsyanko@gmail.com>,
"Max Filippov" <jcmvbkbc@gmail.com>,
"Pierrick Bouvier" <pierrick.bouvier@linaro.org>,
"Michael S. Tsirkin" <mst@redhat.com>,
"Anton Johansson" <anjo@rev.ng>,
"Peter Maydell" <peter.maydell@linaro.org>,
"Cleber Rosa" <crosa@redhat.com>,
"Eric Auger" <eric.auger@redhat.com>,
"Yanan Wang" <wangyanan55@huawei.com>,
qemu-arm@nongnu.org, "Hao Wu" <wuhaotsh@google.com>,
"Mads Ynddal" <mads@ynddal.dk>,
"Sriram Yagnaraman" <sriram.yagnaraman@ericsson.com>,
qemu-riscv@nongnu.org, "Paolo Bonzini" <pbonzini@redhat.com>,
"Jason Wang" <jasowang@redhat.com>,
"Nicholas Piggin" <npiggin@gmail.com>,
"Michael Rolnik" <mrolnik@gmail.com>,
"Zhao Liu" <zhao1.liu@intel.com>,
"Alessandro Di Federico" <ale@rev.ng>,
"Thomas Huth" <thuth@redhat.com>,
"Antony Pavlov" <antonynpavlov@gmail.com>,
"Jiaxun Yang" <jiaxun.yang@flygoat.com>,
"Hanna Reitz" <hreitz@redhat.com>,
"Ilya Leoshkevich" <iii@linux.ibm.com>,
"Marcelo Tosatti" <mtosatti@redhat.com>,
"Nina Schoetterl-Glausch" <nsg@linux.ibm.com>,
"Daniel Henrique Barboza" <danielhb413@gmail.com>,
"Qiuhao Li" <Qiuhao.Li@outlook.com>,
"Hyman Huang" <yong.huang@smartx.com>,
"Daniel P. Berrangé" <berrange@redhat.com>,
"Magnus Damm" <magnus.damm@gmail.com>,
qemu-rust@nongnu.org, "Bandan Das" <bsd@redhat.com>,
"Strahinja Jankovic" <strahinja.p.jankovic@gmail.com>,
"Mark Cave-Ayland" <mark.cave-ayland@ilande.co.uk>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>,
kvm@vger.kernel.org, "Fam Zheng" <fam@euphon.net>,
"Jia Liu" <proljc@gmail.com>,
"Marc-André Lureau" <marcandre.lureau@redhat.com>,
"Alistair Francis" <alistair@alistair23.me>,
"Subbaraya Sundeep" <sundeep.lkml@gmail.com>,
"Kyle Evans" <kevans@freebsd.org>,
"Song Gao" <gaosong@loongson.cn>,
"Alexandre Iooss" <erdnaxe@crans.org>,
"Aurelien Jarno" <aurelien@aurel32.net>,
"Liu Zhiwei" <zhiwei_liu@linux.alibaba.com>,
"Peter Xu" <peterx@redhat.com>,
"Stefan Hajnoczi" <stefanha@redhat.com>,
"BALATON Zoltan" <balaton@eik.bme.hu>,
"Elena Ufimtseva" <elena.ufimtseva@oracle.com>,
"Edgar E. Iglesias" <edgar.iglesias@gmail.com>,
"Frédéric Barrat" <fbarrat@linux.ibm.com>,
qemu-ppc@nongnu.org, "Radoslaw Biernacki" <rad@semihalf.com>,
"Beniamino Galvani" <b.galvani@gmail.com>,
"David Hildenbrand" <david@redhat.com>,
"Richard Henderson" <richard.henderson@linaro.org>,
"David Woodhouse" <dwmw2@infradead.org>,
"Eduardo Habkost" <eduardo@habkost.net>,
"Ahmed Karaman" <ahmedkhaledkaraman@gmail.com>,
"Huacai Chen" <chenhuacai@kernel.org>,
"Mahmoud Mandour" <ma.mandourr@gmail.com>,
"Harsh Prateek Bora" <harshpb@linux.ibm.com>
Subject: Re: [PATCH v2 06/12] python: upgrade to python3.9+ syntax
Date: Thu, 26 Jun 2025 06:54:18 +0200 [thread overview]
Message-ID: <87cyar14sl.fsf@pond.sub.org> (raw)
In-Reply-To: <CAFn=p-YPN6MWZiETi7XWkyYVPpe7uew49CwjEdAsMmW=ZPOx5A@mail.gmail.com> (John Snow's message of "Wed, 25 Jun 2025 13:35:24 -0400")
John Snow <jsnow@redhat.com> writes:
> On Tue, Jun 24, 2025 at 3:34 AM Markus Armbruster <armbru@redhat.com> wrote:
>
>> John Snow <jsnow@redhat.com> writes:
>>
>> > This patch is fully automated, using pymagic, isort and autoflake.
>> >
>> > Create a script named pymagic.sh:
>> >
>> > =========================
>> >
>> > pyupgrade --exit-zero-even-if-changed --keep-percent-format \
>> > --py39-plus "$@"
>> >
>> > autoflake -i "$@"
>> >
>> > isort --settings-file python/setup.cfg \
>> > -p compat -p qapidoc_legacy -p iotests -o qemu "$@"
>> > =========================
>> >
>> > Then, from qemu.git root:
>> >
>> >> find . -type f -name '*.py' | xargs pymagic
>> >> git grep --name-only "#!/usr/bin/env python" | xargs pymagic
>> >
>> > This changes a lot of old Pythonisms, but in particular it upgrades the
>> > old Python type hint paradigm to the new 3.9+ paradigm wherein you no
>> > longer need to import List, Dict, Tuple, Set, etc from the Typing module
>> > and instead directly subscript the built-in types list, dict, tuple,
>> > set, etc. The old-style annotations are deprecated as of 3.9 and are
>> > eligible for removal starting in Python 3.14, though the exact date of
>> > their removal is not yet known.
>> >
>> > pyupgrade updates the imports and type hint paradigms (as well as
>> > updating other old 'isms, such as removing the unicode string
>> > prefix). autoflake in turn then removes any unused import statements,
>> > possibly left behind by pyupgrade. Lastly, isort fixes the import order
>> > and formatting to the standard we use in qemu.git/python and
>> > scripts/qapi in particular.
>> >
>> > Signed-off-by: John Snow <jsnow@redhat.com>
>>
>> [...]
>>
>> > 448 files changed, 1959 insertions(+), 1631 deletions(-)
>>
>> *Ächz*
>>
>
> Gesundheit.
>
>
>>
>> I hate it when people ask me to split up my mechanical patches...
>>
>> One split is by subsystem / maintainer. I've done this a few times, and
>> it's quite a bother. Questionable use of your time if you ask me.
>>
>
> I'd prefer not to unless it is requested of me specifically. I don't think
> most maintainers really care about the nuances of Python and as long as
> their stuff continues to work they're not going to mind much.
>
> Or, to be frank: I don't think this series would ever garner enough review
> and attention to warrant the labor it'd take to tailor it to such a review.
> It's mechanical, it's boring, it should be fine.
>
> I switched from a manual patch series to a tool-driven one specifically to
> make it more mindless and less interesting, and going through and splitting
> it back out is ... eh. I would prefer not to.
>
>
>>
>> There's another split here... Your pymagic.sh runs three tools. If you
>> commit after each one, the patch splits into three.
>>
>
> I use all three because each one alone isn't sufficient to then pass the
> static analysis checks, they each do a little bit of damage that another
> tool corrects afterwards.
>
> pyupgrade works to modernize syntax, but leaves impotent import statements
> hanging.
Import statements it made impotent, I presume.
> autoflake removes those impotent imports.
> isort fixes the import statement ordering and formatting to our standard.
Out of curiosity: what messes up ordering and formatting?
> (And then I do some manual fixups to fix the linting tests where things
> were auto-formatted suboptimally.)
>
> I can still split it out for review purposes, like I did here with some
> manual fixups appended to the end.
>
> Just, for merge, they'll be combined by necessity as a result of our
> no-regressions-for-bisect rule.
I see.
>> I understand you pass --py39-plus to pyupgrade to get the type hints
>> modernized. If you run it without --py39-plus for all the miscellaneous
>> upgrades, commit, then run it with --py39-plus for just the type hint
>> upgrades, commit, the last patch splits again.
>>
>
> I can try it! I actually didn't try running it without py39-plus at all, so
> I don't know what that'll do. but no harm in an experiment.
>
>
>>
>> Thoughts?
>
>
> First and foremost I just thought it'd be good to get this mechanical
> change squared away in one giant patch so we could add this one singular
> horrible mega-commit into the git blame "ignored commits" list to minimize
> the impact of the "flag day".
Point.
Still, it's awfully hard to see what the horrible mega-commit does.
A patch that does one thing entirely mechanically is fine even when it's
huge. Understanding the one thing is easy. I can usually develop
confidence in the patch.
A patch that does many things mechanically can be problematic. If it's
small enough, I can just review them like any other patch. If it's way
too big for that, we have to rely on appeal to authority, i.e. the
tool(s) that generated the patch. Certainly not nothing, but it gives
me an uneasy feeling.
This is why I'm keen to see the type hint upgrade split off. I expect
the type hint part to do one thing entirely mechanically (fine), and I
hope the other part will be small enough to let me build confidence in
it.
> This upgrade will have to happen "eventually" but it needn't be "right
> now", but I figured it'd be good to get it out of the way... or put another
> way, "better my mess than someone else's".
I'd prefer upgrade now rather than later for the Python code I maintain.
next prev parent reply other threads:[~2025-06-26 4:54 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-12 20:54 [PATCH v2 00/12] Python: Fix 'make check-dev' and modernize to 3.9+ John Snow
2025-06-12 20:54 ` [PATCH v2 01/12] python: convert packages to PEP517/pyproject.toml John Snow
2025-06-13 8:36 ` Thomas Huth
2025-06-13 19:36 ` John Snow
2025-06-12 20:54 ` [PATCH v2 02/12] python: update pylint ignores John Snow
2025-06-13 10:18 ` Thomas Huth
2025-06-16 12:05 ` Akihiko Odaki
2025-06-12 20:54 ` [PATCH v2 03/12] python: sync changes from external qemu.qmp package John Snow
2025-06-16 12:12 ` Akihiko Odaki
2025-06-12 20:54 ` [PATCH v2 04/12] python: update shebangs to standard, using /usr/bin/env John Snow
2025-06-13 10:39 ` Thomas Huth
2025-06-16 12:12 ` Akihiko Odaki
2025-06-12 20:54 ` [PATCH v2 05/12] python: fix illegal escape sequences John Snow
2025-06-13 10:41 ` Thomas Huth
2025-06-16 12:13 ` Akihiko Odaki
2025-06-12 20:54 ` [PATCH v2 06/12] python: upgrade to python3.9+ syntax John Snow
2025-06-17 9:15 ` Mads Ynddal
2025-06-17 15:52 ` John Snow
2025-06-24 7:34 ` Markus Armbruster
2025-06-25 17:35 ` John Snow
2025-06-26 4:54 ` Markus Armbruster [this message]
2025-06-12 20:54 ` [PATCH v2 07/12] fixup John Snow
2025-06-12 20:54 ` [PATCH v2 08/12] python: further 3.9+ syntax upgrades John Snow
2025-06-12 20:54 ` [PATCH v2 09/12] python: update mkvenv to type-check under different python versions John Snow
2025-06-12 20:54 ` [PATCH v2 10/12] python: remove version restriction for mypy John Snow
2025-06-12 20:54 ` [PATCH v2 11/12] scripts/codeconverter: remove unused code John Snow
2025-06-12 20:54 ` [PATCH v2 12/12] scripts/codeconverter: remove * imports John Snow
2025-06-16 8:53 ` [PATCH v2 00/12] Python: Fix 'make check-dev' and modernize to 3.9+ Akihiko Odaki
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=87cyar14sl.fsf@pond.sub.org \
--to=armbru@redhat.com \
--cc=Qiuhao.Li@outlook.com \
--cc=ahmedkhaledkaraman@gmail.com \
--cc=ale@rev.ng \
--cc=alex.bennee@linaro.org \
--cc=alistair@alistair23.me \
--cc=alxndr@bu.edu \
--cc=andrew@codeconstruct.com.au \
--cc=anisinha@redhat.com \
--cc=anjo@rev.ng \
--cc=antonynpavlov@gmail.com \
--cc=aurelien@aurel32.net \
--cc=b.galvani@gmail.com \
--cc=balaton@eik.bme.hu \
--cc=berrange@redhat.com \
--cc=borntraeger@linux.ibm.com \
--cc=brian.cain@oss.qualcomm.com \
--cc=bsd@redhat.com \
--cc=chenhuacai@kernel.org \
--cc=clement.mathieu--drif@eviden.com \
--cc=clg@kaod.org \
--cc=crosa@redhat.com \
--cc=danielhb413@gmail.com \
--cc=darren.kenny@oracle.com \
--cc=david@redhat.com \
--cc=davydov-max@yandex-team.ru \
--cc=deller@gmx.de \
--cc=dwmw2@infradead.org \
--cc=eblake@redhat.com \
--cc=edgar.iglesias@gmail.com \
--cc=eduardo@habkost.net \
--cc=elena.ufimtseva@oracle.com \
--cc=emaste@freebsd.org \
--cc=erdnaxe@crans.org \
--cc=eric.auger@redhat.com \
--cc=fam@euphon.net \
--cc=farman@linux.ibm.com \
--cc=farosas@suse.de \
--cc=fbarrat@linux.ibm.com \
--cc=gaosong@loongson.cn \
--cc=harshpb@linux.ibm.com \
--cc=hpoussin@reactos.org \
--cc=hreitz@redhat.com \
--cc=i.mitsyanko@gmail.com \
--cc=iii@linux.ibm.com \
--cc=imp@bsdimp.com \
--cc=jag.raman@oracle.com \
--cc=jamin_lin@aspeedtech.com \
--cc=jasowang@redhat.com \
--cc=jcmvbkbc@gmail.com \
--cc=jiaxun.yang@flygoat.com \
--cc=joel@jms.id.au \
--cc=jsnow@redhat.com \
--cc=kevans@freebsd.org \
--cc=kfting@nuvoton.com \
--cc=kraxel@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=kwolf@redhat.com \
--cc=laurent@vivier.eu \
--cc=leetroy@gmail.com \
--cc=leif.lindholm@oss.qualcomm.com \
--cc=liwei1518@gmail.com \
--cc=lwhsu@freebsd.org \
--cc=ma.mandourr@gmail.com \
--cc=mads@ynddal.dk \
--cc=magnus.damm@gmail.com \
--cc=manos.pitsidianakis@linaro.org \
--cc=marcandre.lureau@redhat.com \
--cc=marcel.apfelbaum@gmail.com \
--cc=mark.cave-ayland@ilande.co.uk \
--cc=michael.roth@amd.com \
--cc=mrolnik@gmail.com \
--cc=mst@redhat.com \
--cc=mtosatti@redhat.com \
--cc=nieklinnenbank@gmail.com \
--cc=npiggin@gmail.com \
--cc=nsg@linux.ibm.com \
--cc=odaki@rsg.ci.i.u-tokyo.ac.jp \
--cc=palmer@dabbelt.com \
--cc=pasic@linux.ibm.com \
--cc=paul@xen.org \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=peterx@redhat.com \
--cc=philmd@linaro.org \
--cc=pierrick.bouvier@linaro.org \
--cc=proljc@gmail.com \
--cc=qemu-arm@nongnu.org \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=qemu-riscv@nongnu.org \
--cc=qemu-rust@nongnu.org \
--cc=qemu-s390x@nongnu.org \
--cc=rad@semihalf.com \
--cc=richard.henderson@linaro.org \
--cc=shentey@gmail.com \
--cc=sriram.yagnaraman@ericsson.com \
--cc=stefanha@redhat.com \
--cc=steven_lee@aspeedtech.com \
--cc=strahinja.p.jankovic@gmail.com \
--cc=sundeep.lkml@gmail.com \
--cc=thuth@redhat.com \
--cc=vsementsov@yandex-team.ru \
--cc=wangyanan55@huawei.com \
--cc=wuhaotsh@google.com \
--cc=yi.l.liu@intel.com \
--cc=yong.huang@smartx.com \
--cc=ysato@users.sourceforge.jp \
--cc=zhao1.liu@intel.com \
--cc=zhiwei_liu@linux.alibaba.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.