microsoft / python-language-server

Microsoft Language Server for Python
Apache License 2.0
915 stars 133 forks source link

Linter does not detect undefined variable in constructor #2068

Open jrsrjrsr opened 4 years ago

jrsrjrsr commented 4 years ago

Nothing happens when using "Python: Run Linting" and there are no messages printed in the "Python" Output screen. I am running on a file for which I have known errors and for which pylint works correctly in the integrated terminal when I run it manually.

I have confirmed:

"python.linting.pylintEnabled": true
"python.linting.enabled": true

I am running a remote session with "WSL: Ubuntu".

More data below.

Steps to reproduce:

Create a file with the following two lines:

x = 3
print(y)

Run the command "Python: Run Linting".

Logs

No log appears in Output for Python code or Developer panel. However, there is a Python error (jediProxy Error) that shows up in the Developer panel. Details are provided in the Logs section below.'

Output for Python in the Output panel:

``` Nothing from the command gets printed here ```


Output from Console under the Developer Tools panel:

``` Nothing appears immediately after running the command. However, prior to running the command, there was the following error: Error Python Extension: 2020-06-07 10:53:14: stderr jediProxy Error (stderr) /home/jordan/.vscode-server-insiders/extensions/ms-python.python-2020.6.85559-dev/pythonFiles/completion.py:586: DeprecationWarning: Deprecated since version 0.16.0. Use Script(...).get_names instead. jedi.api.names(   | t.log | @ | console.ts:137 -- | -- | -- | --   | $logExtensionHostMessage | @ | mainThreadConsole.ts:39   | _doInvokeHandler | @ | rpcProtocol.ts:402   | _invokeHandler | @ | rpcProtocol.ts:387   | _receiveRequest | @ | rpcProtocol.ts:303   | _receiveOneMessage | @ | rpcProtocol.ts:230   | (anonymous) | @ | rpcProtocol.ts:105   | fire | @ | event.ts:587   | fire | @ | ipc.net.ts:453   | _receiveMessage | @ | ipc.net.ts:733   | (anonymous) | @ | ipc.net.ts:592   | fire | @ | event.ts:587   | acceptChunk | @ | ipc.net.ts:239   | (anonymous) | @ | ipc.net.ts:200   | t | @ | ipc.net.ts:28   | emit | @ | events.js:203   | addChunk | @ | _stream_readable.js:295   | readableAddChunk | @ | _stream_readable.js:276   | Readable.push | @ | _stream_readable.js:210   | onStreamRead | @ | internal/stream_base_commons.js:166 ```

karrtikr commented 4 years ago

Please try to find the Python output channel here,

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

Unfortunately without it, there's not much we can do. Also, can you try installing an older version of the extension (for example 2020.4.58038), and see if your problem happens?

You can follow the prompts from "Extensions: Install Specific Version of Extension..." in the command palette:

image

Or you can open the extensions side bar, click on the settings for the Python extension and pick "Install Another Version...":

https://user-images.githubusercontent.com/51720070/80000627-39dacc00-8472-11ea-9755-ac7ba0acbb70.gif

jrsrjrsr commented 4 years ago

Hi,

After installing different versions (v2020.4.76186 and v2020.5.80290) and digging a little further, I noticed that some errors were being picked up, but not others. And, this is happening in both versions of the extension I installed.

Here is a new test case:

XX = 3
print(y)

class TestIt():
    def __init__(self):
        self.x = 5
        slf.y = 6

I expect vscode to produce two Problems in the Problems window associated with the undefined variables y in the second line and slf in the last line. However, the Problems window only shows the first of these two:

Undefined variable: 'y'

Running manually in the terminal window provides the output I expect

> pylint junk3.py | grep E0602
************* Module junk3
junk3.py:2:6: E0602: Undefined variable 'y' (undefined-variable)
junk3.py:8:8: E0602: Undefined variable 'slf' (undefined-variable)
My Python Output Window (while running extension v2020.4.76186)

``` User belongs to experiment group 'AlwaysDisplayTestExplorer - control' User belongs to experiment group 'ShowPlayIcon - start' User belongs to experiment group 'DebugAdapterFactory - experiment' User belongs to experiment group 'PtvsdWheels37 - experiment' User belongs to experiment group 'UseTerminalToGetActivatedEnvVars - control' User belongs to experiment group 'WebHostNotebook - control' User belongs to experiment group 'LocalZMQKernel - control' User belongs to experiment group 'NativeNotebook - control' User belongs to experiment group 'CollectLSRequestTiming - control' User belongs to experiment group 'CollectNodeLSRequestTiming - experiment' User belongs to experiment group 'EnableIPyWidgets - experiment' User belongs to experiment group 'RunByLine - control' > conda --version > pyenv root > python3.7 ~/.vscode-server-insiders/extensions/ms-python.python-2020.4.76186/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)" > python3.6 ~/.vscode-server-insiders/extensions/ms-python.python-2020.4.76186/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)" > python3 ~/.vscode-server-insiders/extensions/ms-python.python-2020.4.76186/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)" > python2 ~/.vscode-server-insiders/extensions/ms-python.python-2020.4.76186/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)" > python ~/.vscode-server-insiders/extensions/ms-python.python-2020.4.76186/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)" > /usr/bin/python3 ~/.vscode-server-insiders/extensions/ms-python.python-2020.4.76186/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)" > conda info --json Python interpreter path: /usr/bin/python3 Starting Microsoft Python language server. > /usr/bin/python3 ~/.vscode-server-insiders/extensions/ms-python.python-2020.4.76186/pythonFiles/pyvsc-run-isolated.py -c "import jupyter" > /usr/bin/python3 ~/.vscode-server-insiders/extensions/ms-python.python-2020.4.76186/pythonFiles/pyvsc-run-isolated.py -c "import jupyter" > /usr/bin/python3 ~/.vscode-server-insiders/extensions/ms-python.python-2020.4.76186/pythonFiles/pyvsc-run-isolated.py -c "import notebook" > /usr/bin/python3 ~/.vscode-server-insiders/extensions/ms-python.python-2020.4.76186/pythonFiles/pyvsc-run-isolated.py -c "import notebook" > conda --version > /usr/bin/autopep8 --diff ~/git/SheetMusicViewer/junk3.py.4dc18e947ccc0718999d843d3930fa9f.py cwd: ~/git/SheetMusicViewer ```

crazyapril commented 4 years ago

Experiencing same problem, running python linting shows nothing (including output: python). Check 'Jedi Enabled' and pylint works well immediately. In my case it seems the problem is not related to recent versions, tried downgrade to 2020.1, still no hint

karrtikr commented 4 years ago

@crazyapril Your issue seems to be that Pylint is not working when using Python Language server as intellisense. We've an open issue for that.

karrtikr commented 4 years ago

Actually Language server is one providing the linting here, not pylint.

XX = 3
print(y)

class TestIt():
    def __init__(self):
        self.x = 5
        slf.y = 6

LS only shows one error Undefined variable: 'y' while pylint shows two, transferring to LS.