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

*: Automated changes from pyupgrade #3403

Merged
merged 9 commits into from
Jun 25, 2024
Merged

Conversation

bdarnell
Copy link
Member

Adopt various new language features throughout the codebase. These changes are all automated by pyupgrade, but I had to modify pyupgrade to disable a change that was incorrect (it wanted to remove a call to str.encode which was used for its side effect to avoid import deadlocks), and to split things up into multiple commits for easier review. The last commit, which converts to fstrings, required running pyupgrade in two passes.

Closes #3391

This was only necessary in python 3.

This change was made with a version of pyupgrade that was modified
to perform only this change.
These features have been available since Python 2.7.

This change was made with a version of pyupgrade modified to perform
only this change, then postprocessed with black.
Another feature that's been around since Python 2.7
Automated change with modified pyupgrade and black.
Various errors were merged into OSError in Python 3.4.

Automated change with modified pyupgrade.
I had missed that this became hard-coded to utf-8 in py3k,
instead of being overridable as in python 2.

Automated change with modified pyupgrade.
This alias existed only for python 2 compatibility.
This commit was partially made by pyupgrade and then I manually fixed
the unused import.
- Unpack list comprehension
- Redundant calls to str() on string literals
- Unnecessary args to super()

With the previous commits, this brings us up to
pyupgrade --py3-plus --keep-percent-format
This makes black use trailing commas consistently across the codebase.
Without this, it uses certain trailing commas only in files that
contain fstrings (because this marks them as requiring Python 3.6+).
Automated change using pyupgrade in two passes (once to go from percent
formatting to str.format, then to go from str.format to f-strings),
followed by black.

This left a few uses of str.format for unknown reasons.
@bdarnell bdarnell merged commit 167d327 into tornadoweb:master Jun 25, 2024
13 checks passed
@bdarnell bdarnell deleted the pyupgrade branch June 25, 2024 18:10
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.

1 participant