pylint doesn't recognize asyncio.subprocess

Created on 5 May 2017  Â·  3Comments  Â·  Source: PyCQA/pylint

Steps to reproduce

  1. Using this test file, example.py:

    from asyncio import subprocess
    
    subprocess.create_subprocess_exec('echo', 'hi')
    
  2. Run pylint example.py

Current behavior

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 ]

Expected behavior

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 output

» 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)]
bug

Most helpful comment

Thanks @JulienPalard This hasn't been fixed yet but we'll get to it.

All 3 comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pylint-bot picture pylint-bot  Â·  3Comments

DGalt picture DGalt  Â·  3Comments

pylint-bot picture pylint-bot  Â·  3Comments

Hubro picture Hubro  Â·  3Comments

GergelyKalmar picture GergelyKalmar  Â·  3Comments