No. Even pylint
, the most powerful and nitpicky Python linter I'm aware of, isn't clever enough to detect this case. But if it were, it would probably complain that you're using locals()
in the first place. :)
On the other hand, and unlike pyflakes, pylint does support magic comments to ignore specific problems. But I must warn you that pylint is extremely picky (and thus slow) out of the box, so you'll want to spend a few minutes upfront to cut its list of checks down to just the things you actually care about.
There is a ticket closed as wontfix for improving this behavior in the specific case of string formatting. It appears that pylint developers don't want to implement this as a feature.