[code-quality] Why does pylint flag this?

Ben Finney ben+python at benfinney.id.au
Thu Apr 20 15:53:53 EDT 2017


Mark Syms <Mark.Syms at citrix.com> writes:

> E: 13,16: Non-iterable value nullfh is used in an iterating context (not-an-iterable)

Bear in mind that PyLint performs static analysis; it doesn't execute
the code, and so does not have access to the Python objects that running
statements produce.

Since Python objects are dynamically typed, a static analysis cannot be
certain of the type of any object.

> However the code is functional so nullfh does work in the iterating
> context.

I expect PyLint makes an incorrect guess about the type of the return
value from ‘tempfile.TemporaryFile()’.

-- 
 \       “You can never entirely stop being what you once were. That's |
  `\   why it's important to be the right person today, and not put it |
_o__)                                 off until tomorrow.” —Larry Wall |
Ben Finney



More information about the code-quality mailing list