2

On codacy it detects an issue where I dont have enough arguments for format string. Help please.

code:

self.notify.error("An item we don't have: track %s level %s was selected." % [track, level]) 
pedrorijo91
  • 7,635
  • 9
  • 44
  • 82
Mgracer
  • 37
  • 1
  • 11

2 Answers2

4

pass a tuple, not a list

self.notify.error("An item we don't have: track %s level %s was selected." % (track, level)) 
Ayush
  • 3,695
  • 1
  • 32
  • 42
  • 2
    Or, if `.error()` is a logging function, omit the tuple altogether and just pass the arguments directly: `self.notify.error("An item we don't have: track %s level %s was selected.", track, level)` – John Gordon Nov 23 '15 at 17:29
2

this is how i fixed it

"An item we don't have: track {} level {} was selected.".format(track, level)
Mgracer
  • 37
  • 1
  • 11
  • 1
    does anyone agree the 2 day wait makes no sense to accept your own answer? – Mgracer Nov 23 '15 at 18:00
  • While this is the preferred way of formatting strings nowadays, this doesn't answer the question as to why you were getting the error in the first place. The first answer does this well. Hence the two day waiting period: you might have a fix, but do you have an answer? – Adam Nov 23 '15 at 18:20