Project-Platypus / Platypus

A Free and Open Source Python Library for Multiobjective Optimization
GNU General Public License v3.0
553 stars 152 forks source link

Use f-strings for string formatting #182

Closed EwoutH closed 2 years ago

EwoutH commented 2 years ago

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. 13 f-strings were created in 4 files.

F-strings are in general more readable, concise and performant. See also: PEP 498#Rationale

Running flynt v.0.76

Execution time:                            1.312s
Files checked:                             41
Files modified:                            3
Character count reduction:                 311 (0.09%)

Per expression type:
Old style (`%`) expressions attempted:     4/11 (36.4%)
`.format(...)` calls attempted:            11/11 (100.0%)
No concatenations attempted.
F-string expressions created:              13
EwoutH commented 2 years ago

Hi @dhadka! Would you be able to take a look at this PR?

dhadka commented 2 years ago

This requires Python 3.6+.

:+1: Given 3.6 has reach EOL, I think it's fine to build this in as a requirement - https://endoflife.date/python

EwoutH commented 2 years ago

I added a commit which sets python_requires to >=3.6 in setup.py, to signal that it needs Python 3.6 from this point.

EwoutH commented 2 years ago

Is anything needed from me to get this merged?

dhadka commented 2 years ago

@EwoutH Merged. Were you unable to see / click the merge button? I might need to adjust the repo permissions if not.

EwoutH commented 2 years ago

Oh I'm used to maintainers merging the PRs, actually didn't look for it. I will let you know on a next PR.