Repository navigation
chore(lint): enable Python 3.10 pyupgrade rules - #8561
Merged
Merged
Conversation
The ruff target has been py310 since #8321, but the three pyupgrade rules that matter for that target were still ignored. Enable them and apply their fixes: builtin generics instead of typing aliases, PEP 604 unions, and collections.abc imports. Two places keep the old form on purpose: the OpenAPI compat mapping that keys typing aliases to builtins, and the batch alias that unions a string placeholder when Pydantic is not installed.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #8561 +/- ##
===========================================
- Coverage 96.91% 96.91% -0.01%
===========================================
Files 317 317
Lines 15964 15952 -12
Branches 1415 1415
===========================================
- Hits 15472 15460 -12
Misses 349 349
Partials 143 143 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Fifty example files lost or gained import lines, which shifted the lines highlighted by the docs. Remap every hl_lines that embeds a changed example so the same statements stay highlighted, and keep the Annotated import in validating_headers.py on one line so its docs annotation reads naturally.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Issue number: closes #8087
Summary
Changes
The ruff target has been
py310since #8321, so the first half of #8087 was already done. This finishes it:UP006,UP007andUP035leavelint.ignore, and their fixes are applied across the library, tests and examples (148 files, mostly autofixed): builtin generics instead oftyping.List/Dict/Type, PEP 604 unions, andcollections.abcimports.Two spots intentionally keep the old form, with a
noqaand a comment: the OpenAPI compat mapping that uses typing aliases as dict keys, and the batch alias that unions a string placeholder when Pydantic is not installed, which|cannot do at runtime.User experience
No behaviour change. Type hints in docs examples now use the 3.10 syntax users already write.
Because 50 example files lost or gained import lines, the docs
hl_linesthat embed them were remapped (57 code blocks across 12 pages) so the same statements stay highlighted. Verified by comparing the highlighted text before and after for every block, and by building the docs locally.Validation
test_with_only_required_packages(no Pydantic) passed; performance tests passed.developin the same environment, so the runtime|aliases evaluate correctly on our oldest supported version.By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.