roskakori / pygount

count lines of code for hundreds of languages using pygments
https://pygount.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
154 stars 22 forks source link

Replace `.format()` with f-strings #166

Open ben05allen opened 1 month ago

ben05allen commented 1 month ago

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().

e-io commented 1 month ago

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.

roskakori commented 1 month ago

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