Skip to content
This repository has been archived by the owner on Apr 14, 2022. It is now read-only.

Linter does not detect undefined variable in constructor #2068

Open
jrsrjrsr opened this issue Jun 7, 2020 · 5 comments · May be fixed by #2070
Open

Linter does not detect undefined variable in constructor #2068

jrsrjrsr opened this issue Jun 7, 2020 · 5 comments · May be fixed by #2070
Labels
bug Something isn't working feature: linter

Comments

@jrsrjrsr
Copy link

jrsrjrsr commented Jun 7, 2020

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.

  • VS Code version: 1.46.0-insider
  • Extension version (available under the Extensions sidebar): v2020.6.85559-dev
  • OS and version: Win 10, Build 19041.264, (Ubuntu, WSL2)
  • Python version (& distribution if applicable, e.g. Anaconda): Python 3.8.2,
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): N/A
  • Relevant/affected Python packages and their versions: ???
  • Relevant/affected Python-related VS Code extensions and their versions: ??
  • Jedi or Language Server? (i.e. what is "python.jediEnabled" set to; more info How to update the language server to the latest stable version vscode-python#3977): This setting doesn't exist
  • Value of the python.languageServer setting: Microsoft

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
Copy link

karrtikr commented Jun 8, 2020

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
Copy link
Author

jrsrjrsr commented Jun 8, 2020

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
Copy link

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
Copy link

karrtikr commented Jun 9, 2020

@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
Copy link

karrtikr commented Jun 9, 2020

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.

@karrtikr karrtikr transferred this issue from microsoft/vscode-python Jun 9, 2020
@karrtikr karrtikr removed their assignment Jun 9, 2020
@MikhailArkhipov MikhailArkhipov changed the title No output when running pylint linter Linter does not detect undefined variable in constructor Jun 9, 2020
@MikhailArkhipov MikhailArkhipov added bug Something isn't working feature: linter labels Jun 9, 2020
@MikhailArkhipov MikhailArkhipov linked a pull request Jun 9, 2020 that will close this issue
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working feature: linter
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants