[code-quality] Spurious unused variable messages

2015-06-10 Thread Skip Montanaro
Code like this: import os import tempfile def func(): (fd, tmpfile) = tempfile.mkstemp(dir="/tmp") os.close(fd) print "{tmpfile}".format(**locals()) generates an unused variable warning for tmpfile, even though it's referenced in the string in the print statem

Re: [code-quality] Spurious unused variable messages

2015-06-10 Thread Ian Cordasco
On Wed, Jun 10, 2015 at 2:26 PM, Skip Montanaro wrote: > Code like this: > > import os > import tempfile > > def func(): > (fd, tmpfile) = tempfile.mkstemp(dir="/tmp") > os.close(fd) > print "{tmpfile}".format(**locals()) > > generates an unused variable warning

Re: [code-quality] Spurious unused variable messages

2015-06-10 Thread Skip Montanaro
On Wed, Jun 10, 2015 at 3:48 PM, Ian Cordasco wrote: > So, I'm not sure how much pylint will read into that statement. It > has to recognize a few things: > > 1. String formatting (admittedly not that hard when the string wasn't >built up, as in this example) As I stated, I think that string

Re: [code-quality] Spurious unused variable messages

2015-06-10 Thread Claudiu Popa
Hi, On Thu, Jun 11, 2015 at 12:02 AM, Skip Montanaro wrote: > > As I stated, I think that string literal formatting will be the most > common form. The token stream around that should look something like > > STRING-LITERAL DOT "format" > > (however that's spelled). What I'm initially intere