NOAA-GSL / ExascaleWorkflowSandbox

Other
2 stars 2 forks source link

Replace .format() function with triple quote strings fstrings #75

Closed NaureenBharwaniNOAA closed 6 months ago

NaureenBharwaniNOAA commented 6 months ago

There are multiple instances where the .format() function is used for inserting variables into triple quoted strings. A far better approach is to use triple quote fstrings.

For example, instead of:

x = """hello {}""".format(name)

it would be better to use:

x=f"""hello {name}"""

We should fix these and stop using the .format() function going forward.

Looking into where the .format() function is used, it seems to be isolated to a single file, tests/test_parsl_flux_mpi_hello.py. I was able to perform a grep -Ri ".format(" src/ tests/ — for all instances of a piece of text and the result being the code section returned with a hit, and grep -Ril ".format(" src/ tests/ — for all instances of a piece of text and the resulting filenames that contain the code sections. It seems there are only six instances of the .format function being used in the file.

tests/test_parsl_flux_mpi_hello.py:    """.format(
tests/test_parsl_flux_mpi_hello.py:    """.format(
tests/test_parsl_flux_mpi_hello.py:    """.format(
tests/test_parsl_flux_mpi_hello.py:    """.format(
tests/test_parsl_flux_mpi_hello.py:    """.format(
tests/test_parsl_flux_mpi_hello.py:    """.format(

closes #74 .