asv icon indicating copy to clipboard operation
asv copied to clipboard

Use f-strings where possible

Open datapythonista opened this issue 2 years ago • 2 comments

xref #909

Since we support Python > 3.7 now, we can make use of f-strings, to make code more readable.

As an example, the next asv code:

machine_env_name = "{}/{}".format(machine, env_name)

or the next, which is equivalent:

machine_env_name = "{0}/{1}".format(machine, env_name)

Could be written as:

machine_env_name = f"{machine}/{env_name}"

(note the f before the string quotes)

There are lots of those in the codebase. This would be good as something to work on during sprints, but we should create smaller issues, for specific files for those.

The next command returns the list of strings to replace: grep -R --exclude-dir="build" --exclude="*.css" ".format(" *

datapythonista avatar Mar 02 '22 13:03 datapythonista

Refer to this example PR #1087

dorothykiz1 avatar Mar 03 '22 19:03 dorothykiz1

@datapythonista and @dorothykiz1 I'm going to work on this to create a couple of examples more for the sprint.

LucyJimenez avatar Mar 09 '22 12:03 LucyJimenez

Closed by #1258.

HaoZeke avatar Apr 30 '23 19:04 HaoZeke