-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Codestyle: modernisations to accompany Python 3.12 baseline #14256
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Codestyle: modernisations to accompany Python 3.12 baseline #14256
Conversation
|
Most of the typing test changes should be reverted. A |
|
Ah, ok. Perhaps the changeset itself isn't worthwhile, in that case - and that's OK. Is it the |
|
(I did feel that perhaps the longer-format |
|
the config is here - Line 133 in cc7c6f4
only a couple of lints are selected. so rather than using pyupgrade, this should ideally be a PR which proposes broadening the enforced pyupgrade lints in the ruff config |
Those two When I mentioned:
...I hadn't noticed that the previous commit, 056818b, had expanded a bunch of f-strings in a way that introduces (I think) slightly-confusing escaping of brackets ( So: I think I'll partially-revert the changes in this branch, by undoing most-if-not-all of the f-string suggestions. |
|
My comment about ruff was more- if we think these are good changes, why don't we change the existing ruff config to do this, instead of using pyupgrade as a one-off |
1 similar comment
|
My comment about ruff was more- if we think these are good changes, why don't we change the existing ruff config to do this, instead of using pyupgrade as a one-off |
|
I suppose we could do; for a few moments I thought doing that might require the use of per-file ignores (which I think are easy to forget about and cause annoying codestyle divergence/drift). The number of affected string literals seems fairly low, though - so perhaps line-level ignore statements could work instead. |
|
Hm; |
…pproach Partially reverts commit d1bc461.
| "TRY300", # Consider moving this statement to an `else` block | ||
| # pyupgrade | ||
| "UP031", # Use format specifiers instead of percent format | ||
| "UP032", # Use f-string instead of `format` call |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@danieleades I think this works well, but it's not really related to Python 3.12 - either we should put it into a separate PR, or alter the description of this one to be more generic.
|
Given that the typing changes in the tests aren't acceptable, and that the f-string changes are fairly minimal, I'll close this as unnecessary. |
Purpose
From commit ad0497b onwards, Python 3.12 is the baseline version required for Sphinx:
sphinx/pyproject.toml
Line 20 in ad0497b
This pull request uses
pyupgradev3.21.2 to upgrade the Sphinx codebase to refresh it given that new baseline.Unusually, running
pyupgrade --py312-plus ...twice (something I did by accident) made a small difference; the result (87aa828) is a nice improvement, so I've included it in the pull request.References
N/A