Skip to content

Update pre-commit hooks #137591

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

Merged
merged 4 commits into from
Aug 10, 2025
Merged

Update pre-commit hooks #137591

merged 4 commits into from
Aug 10, 2025

Conversation

mhsmith
Copy link
Member

@mhsmith mhsmith commented Aug 9, 2025

Split from #137186. That PR no longer needs the zizmor update, but since I've worked out exactly how to do it, we might as well merge it anyway.

@mhsmith mhsmith added skip issue skip news needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes labels Aug 9, 2025
@StanFromIreland StanFromIreland added OS-android infra CI, GitHub Actions, buildbots, Dependabot, etc. and removed OS-android labels Aug 9, 2025
@hugovk
Copy link
Member

hugovk commented Aug 10, 2025

Let's update the other .pre-commit-config.yaml hooks as well by running pre-commit autoupdate --jobs 0.

We're on Ruff v0.11.8.

Ruff 0.12.* gives out a lot of syntax errors, for example: "invalid-syntax: Cannot use type alias statement on Python 3.10 (syntax was added in Python 3.12)"

If you like we can leave those for another time and just bump to to the latest 0.11: v0.11.13.

@mhsmith mhsmith changed the title Update to zizmor version 1.11.0 Update pre-commit hooks Aug 10, 2025
@mhsmith
Copy link
Member Author

mhsmith commented Aug 10, 2025

Ruff 0.12.* gives out a lot of syntax errors, for example: "invalid-syntax: Cannot use type alias statement on Python 3.10 (syntax was added in Python 3.12)"

I fixed this by specifying the target Python version.

hooks:
- id: ruff
name: Run Ruff (lint) on Doc/
args: [--exit-non-zero-on-fix]
files: ^Doc/
- id: ruff
name: Run Ruff (lint) on Lib/test/
args: [--exit-non-zero-on-fix]
args: [--exit-non-zero-on-fix, --target-version=py313]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess a low version was initially chosen to make backports easier?

Anyway, let's move the config to a .ruff.toml file so it also applies if running Ruff directly.

Suggested change
args: [--exit-non-zero-on-fix, --target-version=py313]
args: [--exit-non-zero-on-fix]

We have a top-level that defines target-version = "py310".

Let's override that in Lib/test/.ruff.toml, either:

  • target-version = "py313" like in Doc/.ruff.toml
  • [per-file-target-version] like in Tools/build/.ruff.toml (might be too files many to be worth it)

And we can also remove the t-string files from extend-exclude and put those under [per-file-target-version] for py314.

(Could do the same for test_grammar.py but it has some F811 errors that would need deciding about.)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@mhsmith mhsmith requested a review from AlexWaygood as a code owner August 10, 2025 15:49
Copy link
Member

@hugovk hugovk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

Copy link
Member

@AA-Turner AA-Turner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can be a little more conservative here:

@bedevere-app
Copy link

bedevere-app bot commented Aug 10, 2025

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@mhsmith
Copy link
Member Author

mhsmith commented Aug 10, 2025

I have made the requested changes; please review again.

@bedevere-app
Copy link

bedevere-app bot commented Aug 10, 2025

Thanks for making the requested changes!

@AA-Turner, @hugovk: please review the changes made to this pull request.

@bedevere-app bedevere-app bot requested review from AA-Turner and hugovk August 10, 2025 22:12
Copy link
Member

@AA-Turner AA-Turner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cheers

@AA-Turner AA-Turner enabled auto-merge (squash) August 10, 2025 22:15
@AA-Turner AA-Turner merged commit b36d23f into python:main Aug 10, 2025
45 of 48 checks passed
@miss-islington-app
Copy link

Thanks @mhsmith for the PR, and @AA-Turner for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14.
🐍🍒⛏🤖 I'm not a witch! I'm not a witch!

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Aug 10, 2025
(cherry picked from commit b36d23f)

Co-authored-by: Malcolm Smith <[email protected]>
Co-authored-by: Adam Turner <[email protected]>
@miss-islington-app
Copy link

Sorry, @mhsmith and @AA-Turner, I could not cleanly backport this to 3.13 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker b36d23f58e8ab85b8576ab59c2ce72572c2cb12a 3.13

@bedevere-app
Copy link

bedevere-app bot commented Aug 10, 2025

GH-137621 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.14 bugs and security fixes label Aug 10, 2025
hugovk pushed a commit that referenced this pull request Aug 11, 2025
Co-authored-by: Malcolm Smith <[email protected]>
Co-authored-by: Adam Turner <[email protected]>
webknjaz pushed a commit to webknjaz/cpython that referenced this pull request Aug 11, 2025
Co-authored-by: Adam Turner <[email protected]>
(cherry picked from commit b36d23f)
@bedevere-app
Copy link

bedevere-app bot commented Aug 11, 2025

GH-137641 is a backport of this pull request to the 3.14 branch.

@mhsmith mhsmith removed the needs backport to 3.13 bugs and security fixes label Aug 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
infra CI, GitHub Actions, buildbots, Dependabot, etc. skip issue skip news
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants