-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Add pyupgrade rules to ruff #12953
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
Add pyupgrade rules to ruff #12953
Conversation
S3 Image Test Results (AMD64 / ARM64) 2 files 2 suites 8m 41s ⏱️ Results for commit f040dd5. ♻️ This comment has been updated with latest results. |
7cf76e9
to
97c5a6f
Compare
Test Results - Alternative Providers1 078 tests 730 ✅ 45m 8s ⏱️ Results for commit f040dd5. ♻️ This comment has been updated with latest results. |
Test Results (amd64) - Integration, Bootstrap 5 files 5 suites 2h 20m 24s ⏱️ Results for commit f040dd5. ♻️ This comment has been updated with latest results. |
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.
Awesome! From my perspective this is looking great! The changeset contains some very subtle changes which directly demonstrate why this kind of linting is a good idea to integrate! 💯
The only question that I still have is the same as for the PR in the downstream project:
How should we best merge this in order to cause the minimum amount of friction for other developers? Would be great if you could outline the different steps / the timeline and the implications (i.e. the steps contributors should take), before moving forward.
Thanks @alexrashed! My plan would be the following.
|
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.
LGTM!
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.
LGTM 🚀
202c93b
to
4d3b20b
Compare
See python/cpython#114315 for details
Motivation
This PR introduces Pyupgrade rules to our ruff configuration.
pyupgrade is a tool that automatically upgrades Python syntax to newer versions.
It introduces the same set of rules of pro#4989.
All the rules are automatically applied by the
make format
. They are also part of the pre-commit hook (after amake init-precommit
).Changes
PU
rules to ourruff
configuration. A few rules have been ignored asruff
does not yet provide a fix that guarantees the program's behavior to stay the same.localstack-core/localstack/utils/**
andlocalstack-core/localstack/testing/pytest/**
) as they are imported from the CLI test.__init__
files. The rationale is the same as the companion PR.PU
rules for `tests/aws/services/lambda_/functions/**. These modules are used by Lambda tests that run with a bunch of different runtimes.I added a few self-contained commits to fix minor stuff I encountered, before committing the rules and all the formatting changes:
typing.Union
outside of type annotations (e.g., right-hand side of an assignment), as they can't be safely fixed byruff
.typing.ContextManager
in favor ofcontextlib.AbstractContextManager
. This is an unsafe fix at the moment.json
anddatetime
). I fixed them in 4631eca and 20dca66.Optional[RLock]
toRLock | None
. In our Python version,RLock
is not a type but a factory function. More info in the issue attached to the commit.convert_to_typed_dict
.