Skip to content
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

Enable nearly all pyupgrade rules (except on test cases) #11499

Merged
merged 11 commits into from
Feb 29, 2024

Conversation

Avasam
Copy link
Collaborator

@Avasam Avasam commented Feb 29, 2024

There's more rules that we want than rules we don't want. And with Ruff having a distinction for "unsafe fixes" (not applied by default) the comment "Only enable rules that have safe autofixes" holds less weight.

Rules relevant to code changes:
https://docs.astral.sh/ruff/rules/lru-cache-without-parameters/
https://docs.astral.sh/ruff/rules/f-string/

Even the protobuf-specific ignore could be activated and autofixes run, as they have a redundant (for typeshed at least) Python >= 3.8 check.

Extracted from #11496 , overlaps with #11498

xref plinss/flake8-noqa#22 as with it there would be 1 less noqa

This comment has been minimized.

pyproject.toml Outdated Show resolved Hide resolved

This comment has been minimized.

This comment has been minimized.

@AlexWaygood
Copy link
Member

AlexWaygood commented Feb 29, 2024

Please also ignore UP038 everywhere due to astral-sh/ruff#7871. It doesn't matter for us now, since it only triggers if the target version is set to py310 or higher, but I don't want a nasty pre-commit surprise when we drop support for Python 3.9 :)

This comment has been minimized.

@Avasam
Copy link
Collaborator Author

Avasam commented Feb 29, 2024

Please also ignore UP038 everywhere [...]

Forgot about that one, I even have it in my own personal projects' ignore

This comment has been minimized.

Copy link
Member

@AlexWaygood AlexWaygood left a comment

Choose a reason for hiding this comment

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

Thanks!

pyproject.toml Outdated Show resolved Hide resolved
Co-authored-by: Alex Waygood <[email protected]>
Copy link
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@AlexWaygood AlexWaygood changed the title Being less selective about pyupgrades rules Enable nearly all pyupgrade rules (except on test cases) Feb 29, 2024
@AlexWaygood AlexWaygood merged commit 26e8c00 into python:main Feb 29, 2024
50 checks passed
@Avasam Avasam deleted the less-selective-pyupgrades-rules branch February 29, 2024 18:45
danieleades pushed a commit to danieleades/typeshed that referenced this pull request Mar 1, 2024
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.

2 participants