pygount icon indicating copy to clipboard operation
pygount copied to clipboard

Replace `.format()` with f-strings

Open ben05allen opened this issue 1 year ago • 2 comments
trafficstars

This issue aims to improve the readability and performance of the codebase by replacing .format() method calls with f-strings.

Python 3.6 introduced f-strings (formatted string literals), which provide a more concise and readable way to format strings compared to the .format() method. F-strings are also generally faster.

Identify all instances of .format() in the codebase and refactor them to use f-strings.

Notably, the LineWriter class in write.py uses .format() as the base of its template.

As the oldest Python version supported is 3.8, there is no need to retain .format().

ben05allen avatar Jul 13 '24 13:07 ben05allen

There are only five ".format" calls total in the project:

Screenshot 2024-07-13 at 15 22 58

So, it would not be difficult to replace them with modern f-strings.

e-io avatar Jul 13 '24 13:07 e-io

Looks good, feel free to assign and implement this any time.

roskakori avatar Jul 13 '24 17:07 roskakori