Using this test file, example.py:
from asyncio import subprocess
subprocess.create_subprocess_exec('echo', 'hi')
Run pylint example.py
The following output:
» pylint example.py
No config file found, using default configuration
************* Module example
C: 1, 0: Missing module docstring (missing-docstring)
E: 3, 0: Module 'subprocess' has no 'create_subprocess_exec' member (no-member)
[ more irrelevant output follows ]
The following warning is emitted:
E: 3, 0: Module 'subprocess' has no 'create_subprocess_exec' member (no-member)
But the "subprocess" (asyncio.subprocess) module _does_ have that member. It appears to be getting confused with the non-async subprocess module: if I do subprocess.Popen(…), that _doesn't_ emit a warning, and should. The import from asyncio import subprocess isn't exactly trying to throw Pylint off the scent here.
» pylint --version
No config file found, using default configuration
pylint 1.6.5,
astroid 1.4.9
Python 3.6.1 (default, Mar 23 2017, 16:49:06)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)]
I did a little troubleshooting but wasn't able to fix it yet.
It seems like a bug is in ImportFrom._infer. Goven following test cases, first one passes while second one fails.
class TestClass(unittest.TestCase):
def test_import_aliased(self):
code = '''
import asyncio.subprocess as subprocess
subprocess'''
module_name_node = extract_node(code)
self.assertEqual('asyncio.subprocess', next(module_name_node.infer()).qname())
def test_import_from_aliased(self):
code = '''
from asyncio import subprocess
subprocess'''
module_name_node = extract_node(code)
self.assertEqual('asyncio.subprocess', next(module_name_node.infer()).qname())
bases._infer_stmts is unable to resolve subprocess import to subpackage given inputs passed to it.
For the record I can still reproduce it with
pylint 2.1.1
astroid 2.0.4
Python 3.6.6 (default, Jun 27 2018, 14:44:17)
[GCC 8.1.0]
Thanks @JulienPalard This hasn't been fixed yet but we'll get to it.
Most helpful comment
Thanks @JulienPalard This hasn't been fixed yet but we'll get to it.