Skip to content

Add pyupgrade to pre-commit hooks #9682

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 1 commit into from
Apr 9, 2025
Merged

Conversation

ulgens
Copy link
Contributor

@ulgens ulgens commented Apr 8, 2025

Description

Inspired from @browniebroke 's PR We can and we should automate this type of checks. pyupgrade is a great tool to do that and we already had pre-commit setup in place.

I tried to minimize the changes by excluding %s to f-string conversions but it looks like the code was a bit neglected so the resulting changes are still not so small.

This looks like nitpicking and "churn", but in my experience, pyupgrade and django-upgrade helps a lot to minimize the maintenance efforts.

@browniebroke
Copy link
Member

Yes, I considered adding pyupgrade to do my previous PR, but consciously chose not to as I thought it would introduce more churn than what I was aiming for, but to be honest I was expecting a bigger diff than that. I assume that disabling percent-formt to f-string is helping a lot.

... in my experience, pyupgrade and django-upgrade helps a lot to minimize the maintenance efforts

It could indeed help us cleanup old branches from #9681 as the project drops support for old versions, so might pay off in the long run

@ulgens
Copy link
Contributor Author

ulgens commented Apr 8, 2025

@browniebroke Removing the --keep-percent-format arg creates an additional diff of 24 files changed, 43 insertions(+), 43 deletions(-); which I still think it's not that big but feels more churn-y. Having all changes handled in a single commit is another option.

I wanted to go with minimal changes to be safer but we can use it without excluding any rules.

@browniebroke
Copy link
Member

I wanted to go with minimal changes to be safer but we can use it without excluding any rules.

Yes I agree, that makes sense to keep changes to a minimum 👍

Copy link
Member

@auvipy auvipy left a comment

Choose a reason for hiding this comment

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

looks good

@auvipy auvipy requested a review from Copilot April 9, 2025 06:21
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 21 out of 21 changed files in this pull request and generated no comments.

@auvipy auvipy merged commit ea1da76 into encode:master Apr 9, 2025
7 checks passed
@ulgens ulgens deleted the pyupgrade-precommit branch April 9, 2025 07:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants