Search code examples
pythonpylint

Pylint E1103 False Positive?


Following my previous question ("Pylint E0202 False Positive?") here is another one (quite specific I guess)

we are using the module subprocess to execute a, well, subprocess.
Creating an example code resulted in the following:

"Example code for E1103"

import subprocess

pipeOpen = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)

(responseData, errorData) = pipeOpen.communicate()

print "Error code: '%s'. Error data: '%s'" % (pipeOpen.returncode, errorData.strip("\n").strip("\r"))

Pylint will say though:

E1103: 9,67: Instance of 'list' has no 'strip' member (but some types could not be inferred)

Looking in to pipeOpen.communicate() it goes down to _communicate. And indeed, stderr is initialised to a list, however, before the return if self.universal_newlines is true then it'll convert the list to a string with newlines.

Is this a case of #pylint: ignore-msg=E1103 or better report it to pylint devs?


Solution

  • well, if print(pipeOpen.universal_newlines and hasattr(file, 'newlines')) returns True and you don't get any errors while actually running the code, then you should report this to pylint developers + ignore the message in the meantime