Pylint: Consider nudging users towards using f-strings

Created on 5 May 2020  路  2Comments  路  Source: PyCQA/pylint

Python 3.5 is end-of-life in September 2020. Since Python 3.6 introduced f-strings, there is no good reason to interpolate _literal strings_ with the string interpolation operator

'Python %f' % version

or the format method

'Python {}'.format(version)

鈥攅xcept when the arguments involve unpacking:

'Python {} or {}`.format(*versions)

Can we consider a pylint warning to nudge users towards using f-strings when possible? It would be extremely helpful to write the f-string for them. For example:

a.py:1:0: W999: Not using f-string: f"Python {version}" (not-using-fstring)

What do you think?

enhancement

Most helpful comment

It seems reasonable to me. I just think that the message should be a convention instead of a warning.

All 2 comments

Seconded, especially since f-strings are a lot faster in practice as well.

It seems reasonable to me. I just think that the message should be a convention instead of a warning.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

adamtheturtle picture adamtheturtle  路  3Comments

glmdgrielson picture glmdgrielson  路  3Comments

elirnm picture elirnm  路  3Comments

lancelote picture lancelote  路  3Comments

DGalt picture DGalt  路  3Comments