Pyupgrade 3.8: Update syntax with Python 3.8+ features#113
Merged
quaquel merged 2 commits intoquaquel:masterfrom Apr 22, 2022
Merged
Pyupgrade 3.8: Update syntax with Python 3.8+ features#113quaquel merged 2 commits intoquaquel:masterfrom
quaquel merged 2 commits intoquaquel:masterfrom
Conversation
Reformats all the text from the old "%-formatted" and .format(...) format to the newer f-string format, as defined in PEP 498. This requires Python 3.6+. Flynt 0.76 was used to reformat the strings. 94 f-strings were created in 26 files. F-strings are in general more readable, concise and performant. See also: https://www.python.org/dev/peps/pep-0498/#rationale
Updated Python code with Python 3.8+ features:
- utf-8 encoding is now the default (PEP 3120)
- Replace list comprehensions by Generator Expressions (PEP 289)
- Replace yield loop by yield from (PEP 380)
- Remove the (object) subclass when defining a class
- Replace the IOError alias by OSError (PEP 3151)
- Define sets with curly braces {} instead of set()
- Remove "r" parameter from open function, which is default
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR updates the Python code with Python 3.8+, removing old, depreciated and redundant code. The biggest advantage is increased readability of the code.
This includes:
yieldloop byyield from(PEP 380, Python 3.3+)(object)when defining a class{}instead ofset()"r"parameter from open function, which is defaultUsed flynt 0.76 for f-string replacement and pyupgrade 2.32.0 with
--py38-plusfor all other Python features.