-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Apply assorted Pyugrade suggestions #4056
Conversation
3b8aadb
to
5a9a97e
Compare
5a9a97e
to
82193a6
Compare
82193a6
to
a1b2d2d
Compare
a1b2d2d
to
2f36dd6
Compare
eecbde6
to
74aefcd
Compare
Given that setuptools uses ruff, you could enforce and autofix this with https://docs.astral.sh/ruff/rules/#pyupgrade-up |
I have selected the pyupgrade suggestions that make most sense and are usually accepted in other projects. Would you agree to giving all pyupgrade suggestions a try, including redundant Also, applying ruff-pyupgrade fixes now would be (partially?) redundant with your #4096. Perhaps we can apply these two pull requests first, then set up ruff-pyupgrade and discuss any remaining rules to apply. |
1119685
to
9a983b2
Compare
That one is often opinionated (and one of the best examples making Ruff's configurability better than pyupgrade directly, along with string formatting). So I'd leave that up to maintainers to decide.
#4096 does not aim at "upgrading code to newer syntax", just removing obsolete code paths/aliases and updating comments.. It's also never redundant to prevent code style/quality regressions imo. (that's what linters are for)
My guess is that's probably what would be preferred. |
pyupgrade appears to be removing obsolete code paths too, at least partially. |
In Python 3, io.open() is an alias for the builtin open() function. https://docs.python.org/3/library/io.html#io.open This is a suggestion from pyupgrade: https://github.com/asottile/pyupgrade#open-alias
In Python ≥ 3.3, IOError is an alias of OSError. https://docs.python.org/3/library/exceptions.html#IOError This is a suggestion from pyupgrade: https://github.com/asottile/pyupgrade#oserror-aliases
This is a suggestion from pyupgrade: https://github.com/asottile/pyupgrade#yield--yield-from
In Python ≥ 3.3, socket.error is an alias of OSError. https://docs.python.org/3/library/socket.html#socket.error This is a suggestion from pyupgrade: https://github.com/asottile/pyupgrade#oserror-aliases
Starting with Python ≥ 3.8, lru_cache can be used as a straight decorator with no arguments: https://bugs.python.org/issue36772 This is a suggestion from pyupgrade: https://github.com/asottile/pyupgrade#remove-parentheses-from-functoolslru_cache
9a983b2
to
3aec0a3
Compare
Not sure why the diff-cover is failing... I thought it would just measure the difference between files. This PR is not making much of a difference regarding that... I will try to re-run the failing CI, if it is only the |
Thank you very much! I agree that an approach for automatic corrections would be nice, but I also agree that we should incrementally build up to the point we can adopt it first. |
Summary of changes
Apply some suggestions from pyupgrade.
Pull Request Checklist
newsfragments/
.(See documentation for details)