Search code examples
pythonpycharmpep

Why PyCharm shows lint error "too few arguments for format string" for mixed keyword and position placeholder?


Consider the following code:

s = 'ab{}cd{mykey}ef{}gh'.format('01', '23', mykey='45')
print(s)

There are 3 placeholders: two positional and one keyword. I've provided enough arguments and the script runs normally, producing the following output:

ab01cd45ef23gh

But PyCharm warns me the following:

enter image description here

My questions are:

  1. Why PyCharm warns that?
  2. Should I disable that warning, and how?
  3. Or, maybe this kind of code (mixed positional and keyword placeholder) is deprecated by Python? Any document says that?

I'm using PyCharm Community 2018.1 EAP and Python 3.7.5


Solution

  • Update your PyCharm (2020.1.3 is the latest at the moment). This is an IDE bug, and it was already fixed since 2018.