microsoft / vscode-python

Python extension for Visual Studio Code
https://aka.ms/pvsc-marketplace
MIT License
4.33k stars 1.19k forks source link

pylint on save producing different results than when run manually #1648

Closed ChrisK91 closed 6 years ago

ChrisK91 commented 6 years ago

Environment data:

Actual behavior

Using a minimal configuration, pylint seems to mishandle installed modules. While respecting the .pylintrc file, pylint still raises errors for installed modules. Running pylint manually - within the same environment - correctly finds the installed modules.

Expected behavior

Running pylint on save should produce the same results as when run manually from within the selected environment (compare output listed below, highlighted with ▶️ )

Steps to reproduce:

  1. Set up environment as indicated above
  2. Create a new folder with a minimal .pylintrc containing
    [MASTER]
    extension-pkg-whitelist=PyQt5
  3. Create a minimal python file ("run.py") requiring PyQt5:
    
    import sys
    from PyQt5.QtWidgets import QApplication, QWidget

app = QApplication(sys.argv) mw = QWidget() mw.show() sys.exit(app.exec_())

4. Open the folder via the "Open Folder" command in VSCode and wait for environments to update (no longer display "cached"
5. Select the newly created "testenv" via select linter
6. Run pylint via "run linting" or by saving
7. Verify that the application actually works via F5 -> "python"
8. Create a python command line via "Python: Create terminal"
9. Run "pylint run.py"

## Logs
Packages installed with conda

Package plan for installation in environment D:\Anaconda3\envs\testenv:

The following NEW packages will be INSTALLED:

astroid:           1.6.3-py36_0
ca-certificates:   2018.03.07-0
certifi:           2018.4.16-py36_0
colorama:          0.3.9-py36h029ae33_0
icu:               58.2-ha66f8fd_1
isort:             4.3.4-py36_0
jpeg:              9b-hb83a4c4_2
lazy-object-proxy: 1.3.1-py36hd1c21d2_0
libpng:            1.6.34-h79bbb47_0
mccabe:            0.6.1-py36hb41005a_1
openssl:           1.0.2o-h8ea7d77_0
pip:               10.0.1-py36_0
pylint:            1.8.4-py36_0
pyqt:              5.9.2-py36h1aa27d4_0
python:            3.6.5-h0c2934d_0
qt:                5.9.5-vc14he4a7d60_0
setuptools:        39.1.0-py36_0
sip:               4.19.8-py36h6538335_0
six:               1.11.0-py36h4db2310_1
sqlite:            3.23.1-h35aae40_0
vc:                14-h0510ff6_3
vs2015_runtime:    14.0.25123-3
wheel:             0.31.0-py36_0
wincertstore:      0.2-py36h7fe50ca_0
wrapt:             1.10.11-py36he5f5981_0
zlib:              1.2.11-h8395fce_2

 ▶️ ** Output for manual ```pylint run.py```**

PS C:\Users*\Desktop\test_folder> pylint run.py Using config file C:\Users*\Desktop\test_folder.pylintrc ***** Module run C: 1, 0: Missing module docstring (missing-docstring) C: 4, 0: Constant name "app" doesn't conform to UPPER_CASE naming style (invalid-name) C: 5, 0: Constant name "mw" doesn't conform to UPPER_CASE naming style (invalid-name)


Your code has been rated at 5.00/10 (previous run: 5.00/10, +0.00)


 ▶️ ** Output for `Python` in the `Output` panel**

##########Linting Output - pylint########## Using config file c:\Users***\Desktop\test_folder.pylintrc ***** Module run 1,0,convention,C0111:Missing module docstring 2,0,error,E0611:No name 'QApplication' in module 'PyQt5.QtWidgets' 2,0,error,E0611:No name 'QWidget' in module 'PyQt5.QtWidgets' 4,0,convention,C0103:Constant name "app" doesn't conform to UPPER_CASE naming style 5,0,convention,C0103:Constant name "mw" doesn't conform to UPPER_CASE naming style


Your code has been rated at -11.67/10 (previous run: -3.33/10, -8.33)


Output from `Console` under the `Developer Tools` panel (toggle Developer Tools on under `Help`)

mainThreadExtensionService.ts:44 TypeError: Cannot read property 'document' of undefined at activateOnEnter (C:\Users*.vscode\extensions\njpwerner.autodocstring-0.2.1\out\src\extension.js:19:35) at context.subscriptions.push.vs.workspace.onDidChangeTextDocument.changeEvent (C:\Users*.vscode\extensions\njpwerner.autodocstring-0.2.1\out\src\extension.js:13:90) at e.fire (d:\Program Files (x86)\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:89:496) at e.$acceptModelChanged (d:\Program Files (x86)\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:647:362) at e._doInvokeHandler (d:\Program Files (x86)\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:598:894) at e._invokeHandler (d:\Program Files (x86)\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:598:612) at e._receiveRequest (d:\Program Files (x86)\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:597:682) at e._receiveOneMessage (d:\Program Files (x86)\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:597:451) at d:\Program Files (x86)\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:596:384 at d:\Program Files (x86)\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:599:463 at d:\Program Files (x86)\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:88:119 at e.fire (d:\Program Files (x86)\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:89:496) at Socket. (d:\Program Files (x86)\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:145:1008) at emitOne (events.js:96:13) at Socket.emit (events.js:191:7) at readableAddChunk (_stream_readable.js:178:18) at Socket.Readable.push (_stream_readable.js:136:10) at Pipe.onread (net.js:560:20) e.$onExtensionRuntimeError @ mainThreadExtensionService.ts:44 mainThreadExtensionService.ts:43 [njpwerner.autodocstring]Cannot read property 'document' of undefined e.$onExtensionRuntimeError @ mainThreadExtensionService.ts:43 mainThreadExtensionService.ts:44 TypeError: Cannot read property 'document' of undefined at activateOnEnter (C:\Users*.vscode\extensions\njpwerner.autodocstring-0.2.1\out\src\extension.js:19:35) at context.subscriptions.push.vs.workspace.onDidChangeTextDocument.changeEvent (C:\Users*.vscode\extensions\njpwerner.autodocstring-0.2.1\out\src\extension.js:13:90) at e.fire (d:\Program Files (x86)\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:89:496) at e.$acceptModelChanged (d:\Program Files (x86)\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:647:362) at e._doInvokeHandler (d:\Program Files (x86)\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:598:894) at e._invokeHandler (d:\Program Files (x86)\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:598:612) at e._receiveRequest (d:\Program Files (x86)\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:597:682) at e._receiveOneMessage (d:\Program Files (x86)\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:597:451) at d:\Program Files (x86)\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:596:384 at d:\Program Files (x86)\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:599:463 at d:\Program Files (x86)\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:88:119 at e.fire (d:\Program Files (x86)\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:89:496) at Socket. (d:\Program Files (x86)\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:145:1008) at emitOne (events.js:96:13) at Socket.emit (events.js:191:7) at readableAddChunk (_stream_readable.js:178:18) at Socket.Readable.push (_stream_readable.js:136:10) at Pipe.onread (net.js:560:20) e.$onExtensionRuntimeError @ mainThreadExtensionService.ts:44 mainThreadExtensionService.ts:43 [njpwerner.autodocstring]Cannot read property 'rangeLength' of undefined e.$onExtensionRuntimeError @ mainThreadExtensionService.ts:43 e._doInvokeHandler @ rpcProtocol.ts:265 e._invokeHandler @ rpcProtocol.ts:250 e._receiveRequest @ rpcProtocol.ts:196 e._receiveOneMessage @ rpcProtocol.ts:178 (anonymous) @ rpcProtocol.ts:111 (anonymous) @ rpcProtocol.ts:307 e.fire @ event.ts:140 (anonymous) @ ipc.net.ts:81 emitOne @ events.js:96 emit @ events.js:191 readableAddChunk @ _stream_readable.js:178 Readable.push @ _stream_readable.js:136 onread @ net.js:560 mainThreadExtensionService.ts:44 TypeError: Cannot read property 'rangeLength' of undefined at activateOnEnter (C:\Users*.vscode\extensions\njpwerner.autodocstring-0.2.1\out\src\extension.js:21:38) at context.subscriptions.push.vs.workspace.onDidChangeTextDocument.changeEvent (C:\Users*.vscode\extensions\njpwerner.autodocstring-0.2.1\out\src\extension.js:13:90) at e.fire (d:\Program Files (x86)\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:89:496) at e.$acceptDirtyStateChanged (d:\Program Files (x86)\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:647:127) at e._doInvokeHandler (d:\Program Files (x86)\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:598:894) at e._invokeHandler (d:\Program Files (x86)\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:598:612) at e._receiveRequest (d:\Program Files (x86)\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:597:682) at e._receiveOneMessage (d:\Program Files (x86)\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:597:451) at d:\Program Files (x86)\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:596:384 at d:\Program Files (x86)\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:599:463 at d:\Program Files (x86)\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:88:119 at e.fire (d:\Program Files (x86)\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:89:496) at Socket. (d:\Program Files (x86)\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:145:1008) at emitOne (events.js:96:13) at Socket.emit (events.js:191:7) at readableAddChunk (_stream_readable.js:178:18) at Socket.Readable.push (_stream_readable.js:136:10) at Pipe.onread (net.js:560:20) e.$onExtensionRuntimeError @ mainThreadExtensionService.ts:44 e._doInvokeHandler @ rpcProtocol.ts:265 e._invokeHandler @ rpcProtocol.ts:250 e._receiveRequest @ rpcProtocol.ts:196 e._receiveOneMessage @ rpcProtocol.ts:178 (anonymous) @ rpcProtocol.ts:111 (anonymous) @ rpcProtocol.ts:307 e.fire @ event.ts:140 (anonymous) @ ipc.net.ts:81 emitOne @ events.js:96 emit @ events.js:191 readableAddChunk @ _stream_readable.js:178 Readable.push @ _stream_readable.js:136 onread @ net.js:560 mainThreadExtensionService.ts:43 [njpwerner.autodocstring]Cannot read property 'rangeLength' of undefined e.$onExtensionRuntimeError @ mainThreadExtensionService.ts:43 e._doInvokeHandler @ rpcProtocol.ts:265 e._invokeHandler @ rpcProtocol.ts:250 e._receiveRequest @ rpcProtocol.ts:196 e._receiveOneMessage @ rpcProtocol.ts:178 (anonymous) @ rpcProtocol.ts:111 (anonymous) @ rpcProtocol.ts:307 e.fire @ event.ts:140 (anonymous) @ ipc.net.ts:81 emitOne @ events.js:96 emit @ events.js:191 readableAddChunk @ _stream_readable.js:178 Readable.push @ _stream_readable.js:136 onread @ net.js:560 mainThreadExtensionService.ts:44 TypeError: Cannot read property 'rangeLength' of undefined at activateOnEnter (C:\Users*.vscode\extensions\njpwerner.autodocstring-0.2.1\out\src\extension.js:21:38) at context.subscriptions.push.vs.workspace.onDidChangeTextDocument.changeEvent (C:\Users*.vscode\extensions\njpwerner.autodocstring-0.2.1\out\src\extension.js:13:90) at e.fire (d:\Program Files (x86)\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:89:496) at e.$acceptDirtyStateChanged (d:\Program Files (x86)\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:647:127) at e.$acceptModelSaved (d:\Program Files (x86)\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:646:830) at e._doInvokeHandler (d:\Program Files (x86)\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:598:894) at e._invokeHandler (d:\Program Files (x86)\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:598:612) at e._receiveRequest (d:\Program Files (x86)\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:597:682) at e._receiveOneMessage (d:\Program Files (x86)\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:597:451) at d:\Program Files (x86)\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:596:384 at d:\Program Files (x86)\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:599:463 at d:\Program Files (x86)\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:88:119 at e.fire (d:\Program Files (x86)\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:89:496) at Socket. (d:\Program Files (x86)\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:145:1008) at emitOne (events.js:96:13) at Socket.emit (events.js:191:7) at readableAddChunk (_stream_readable.js:178:18) at Socket.Readable.push (_stream_readable.js:136:10) at Pipe.onread (net.js:560:20)

brettcannon commented 6 years ago

I can't reproduce. Maybe PyQt5 is not installed for the selected interpreter but is for the one you used to install pylint?