Skip to content

Pyupgrade 3.8: Update syntax with Python 3.8+ features#113

Merged
quaquel merged 2 commits intoquaquel:masterfrom
EwoutH:pyupgrade-38
Apr 22, 2022
Merged

Pyupgrade 3.8: Update syntax with Python 3.8+ features#113
quaquel merged 2 commits intoquaquel:masterfrom
EwoutH:pyupgrade-38

Conversation

@EwoutH
Copy link
Copy Markdown
Collaborator

@EwoutH EwoutH commented Apr 21, 2022

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:

  • f-string formatting of strings (PEP 498, Python 3.6+)
  • utf-8 encoding is now the default (PEP 3120, Python 3.0+)
  • Replace list comprehensions by Generator Expressions (PEP 289, Python 2.4+)
  • Replace yield loop by yield from (PEP 380, Python 3.3+)
  • Replace the IOError alias by OSError (PEP 3151, Python 3.3+)
  • Remove the default subclass (object) when defining a class
  • Define sets with curly braces {} instead of set()
  • Remove "r" parameter from open function, which is default

Used flynt 0.76 for f-string replacement and pyupgrade 2.32.0 with --py38-plus for all other Python features.

EwoutH added 2 commits April 21, 2022 19:26
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
@coveralls
Copy link
Copy Markdown

Coverage Status

Coverage remained the same at 80.506% when pulling 43382b1 on EwoutH:pyupgrade-38 into 1f8d399 on quaquel:master.

@quaquel quaquel merged commit 1495e68 into quaquel:master Apr 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants