John Snow <js...@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 <js...@redhat.com>
[...] > 448 files changed, 1959 insertions(+), 1631 deletions(-) *Ächz* 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. There's another split here... Your pymagic.sh runs three tools. If you commit after each one, the patch splits into three. 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. Thoughts?