[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 4/8] python: use 3.9+ builtin type hints
From: |
Markus Armbruster |
Subject: |
Re: [PATCH 4/8] python: use 3.9+ builtin type hints |
Date: |
Tue, 20 May 2025 11:26:16 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
John Snow <jsnow@redhat.com> writes:
> This patch changes type hints that have built-in equivalents as of
> Python 3.9. The versions we currently use, imported from the typing
> module, have been deprecated since 3.9 and may be removed at any time -
> though to my knowledge, they are not scheduled for removal in 3.14.
>
> The type hints to update are:
>
> typing.Dict => dict
> typing.List => list
> typing.Tuple => tuple
> typing.Set => set
> typing.Type => type
>
> I performed this change the dumb way (I couldn't work out for the life
> of me how to beg ls-files to exclude subprojects and empty directories,
> desipte it having an option which claims to do precisely that. Suggest a
> nicer way to do this if you'd like.)
>
> git ls-files | grep -v 'roms/' | grep -v 'subprojects/' | grep -v
> 'tests/lcitool/libvirt-ci' | xargs sed -i -e 's/Dict\[/dict\[/g'
> git ls-files | grep -v 'roms/' | grep -v 'subprojects/' | grep -v
> 'tests/lcitool/libvirt-ci' | xargs sed -i -e 's/List\[/list\[/g'
> git ls-files | grep -v 'roms/' | grep -v 'subprojects/' | grep -v
> 'tests/lcitool/libvirt-ci' | xargs sed -i -e 's/Tuple\[/tuple\[/g'
> git ls-files | grep -v 'roms/' | grep -v 'subprojects/' | grep -v
> 'tests/lcitool/libvirt-ci' | xargs sed -i -e 's/Set\[/set\[/g'
> git ls-files | grep -v 'roms/' | grep -v 'subprojects/' | grep -v
> 'tests/lcitool/libvirt-ci' | xargs sed -i -e 's/Type\[/type\[/g'
>
> I then used "git add -p" and excluded changes by hand that weren't
> appropriate. I then reviewed all of the changed files by hand to review
> the imports and update them accordingly.
>
> Signed-off-by: John Snow <jsnow@redhat.com>
I'd expect to catch mistakes in the manual parts. I gave scripts/qapi/
an eye-over anyway, and it looks good to me.
Acked-by: Markus Armbruster <armbru@redhat.com>
- [PATCH 0/8] Python: Fix 'make check-dev' and modernize to 3.9+, John Snow, 2025/05/19
- [PATCH 1/8] python: convert packages to PEP517/pyproject.toml, John Snow, 2025/05/19
- [PATCH 2/8] python: update pylint ignores, John Snow, 2025/05/19
- [PATCH 3/8] python: sync changes from external qemu.qmp package, John Snow, 2025/05/19
- [PATCH 4/8] python: use 3.9+ builtin type hints, John Snow, 2025/05/19
- Re: [PATCH 4/8] python: use 3.9+ builtin type hints,
Markus Armbruster <=
- [PATCH 5/8] python: convert remaining deprecated type hints for 3.9+, John Snow, 2025/05/19
- [PATCH 6/8] python: clean up requirements for 3.9+, John Snow, 2025/05/19
- [PATCH 7/8] python: update mkvenv to type-check under different python versions, John Snow, 2025/05/19
- [PATCH 8/8] python: remove version restriction for mypy, John Snow, 2025/05/19
- Re: [PATCH 0/8] Python: Fix 'make check-dev' and modernize to 3.9+, Markus Armbruster, 2025/05/20