why are pylint's error squiggle lines not showing in python visual studio code?
Asked Answered
A

5

6

i'm using vscode for python3 in Ubuntu. Error-squiggle-lines have stopped working for Python(it works for other languages). And I am using Microsoft's Python extension.
vscode v1.41.1 Ubuntu v18.04

this is what i have tried:

  • I thought maybe it's because i installed anaconda so uninstalled it but didn't fix it.
  • then I re-installed vs code after deleting its config from .config/code but that didn't work either.
  • also set python linting to true from command palette

it's not showing error squiggle lines: my vscode looks like this:

here is the Microsoft's python extension's contributions regarding linting(sorry for poor readability):

Whether to lint Python files.   true python.linting.flake8Args  Arguments passed in. Each argument is a separate item in the array.  python.linting.flake8CategorySeverity.E    Severity of Flake8 message type 'E'.    Error python.linting.flake8CategorySeverity.F   Severity of Flake8 message type 'F'.    Error python.linting.flake8CategorySeverity.W   Severity of Flake8 message type 'W'.    Warning python.linting.flake8Enabled    Whether to lint Python files using flake8   false python.linting.flake8Path Path to flake8, you can use a custom version of flake8 by modifying this setting to include the full path.  flake8 python.linting.ignorePatterns    Patterns used to exclude files or folders from being linted.    .vscode/*.py,**/site-packages/**/*.py python.linting.lintOnSave Whether to lint Python files when saved.    true python.linting.maxNumberOfProblems Controls the maximum number of problems produced by the server. 100 python.linting.banditArgs   Arguments passed in. Each argument is a separate item in the array.  python.linting.banditEnabled   Whether to lint Python files using bandit.  false python.linting.banditPath Path to bandit, you can use a custom version of bandit by modifying this setting to include the full path.  bandit python.linting.mypyArgs  Arguments passed in. Each argument is a separate item in the array. --ignore-missing-imports,--follow-imports=silent,--show-column-numbers python.linting.mypyCategorySeverity.error    Severity of Mypy message type 'Error'.  Error python.linting.mypyCategorySeverity.note  Severity of Mypy message type 'Note'.   Information python.linting.mypyEnabled  Whether to lint Python files using mypy.    false python.linting.mypyPath   Path to mypy, you can use a custom version of mypy by modifying this setting to include the full path.  mypy python.linting.pycodestyleArgs Arguments passed in. Each argument is a separate item in the array.  python.linting.pycodestyleCategorySeverity.E   Severity of pycodestyle message type 'E'.   Error python.linting.pycodestyleCategorySeverity.W  Severity of pycodestyle message type 'W'.   Warning python.linting.pycodestyleEnabled   Whether to lint Python files using pycodestyle  false python.linting.pycodestylePath    Path to pycodestyle, you can use a custom version of pycodestyle by modifying this setting to include the full path.    pycodestyle python.linting.prospectorArgs   Arguments passed in. Each argument is a separate item in the array.  python.linting.prospectorEnabled   Whether to lint Python files using prospector.  false python.linting.prospectorPath Path to Prospector, you can use a custom version of prospector by modifying this setting to include the full path.  prospector python.linting.pydocstyleArgs    Arguments passed in. Each argument is a separate item in the array.  python.linting.pydocstyleEnabled   Whether to lint Python files using pydocstyle   false python.linting.pydocstylePath Path to pydocstyle, you can use a custom version of pydocstyle by modifying this setting to include the full path.  pydocstyle python.linting.pylamaArgs    Arguments passed in. Each argument is a separate item in the array.  python.linting.pylamaEnabled   Whether to lint Python files using pylama.  false python.linting.pylamaPath Path to pylama, you can use a custom version of pylama by modifying this setting to include the full path.  pylama python.linting.pylintArgs    Arguments passed in. Each argument is a separate item in the array.  python.linting.pylintCategorySeverity.convention   Severity of Pylint message type 'Convention/C'. Information python.linting.pylintCategorySeverity.error Severity of Pylint message type 'Error/E'.  Error python.linting.pylintCategorySeverity.fatal   Severity of Pylint message type 'Fatal/F'.  Error python.linting.pylintCategorySeverity.refactor    Severity of Pylint message type 'Refactor/R'.   Hint python.linting.pylintCategorySeverity.warning  Severity of Pylint message type 'Warning/W'.    Warning python.linting.pylintEnabled    Whether to lint Python files using pylint.  true python.linting.pylintPath  Path to Pylint, you can use a custom version of pylint by modifying this setting to include the full path.  pylint python.linting.pylintUseMinimalCheckers  Whether to run Pylint with minimal set of rules.    true

python.linting.pylintEnabled is: true

python.linting.pylintPath is: pylint

all the errors in visual studio's console of developer tools:

console.ts:137 [Extension Host] Error Python Extension: 2020-01-18 18:35:53: Failed to serialize gatherRules for DATASCIENCE.SETTINGS [TypeError: Cannot convert object to primitive value  at Array.join (<anonymous>) at Array.toString (<anonymous>) at /home/manik/.vscode/extensions/ms-python.python-2020.1.58038/out/client/extension.js:1:12901 at Array.forEach (<anonymous>)  at Object.l [as sendTelemetryEvent] (/home/manik/.vscode/extensions/ms-python.python-2020.1.58038/out/client/extension.js:1:12818)  at C.sendSettingsTelemetry (/home/manik/.vscode/extensions/ms-python.python-2020.1.58038/out/client/extension.js:75:707093) at C.r.value (/home/manik/.vscode/extensions/ms-python.python-2020.1.58038/out/client/extension.js:1:87512) at Timeout._onTimeout (/home/manik/.vscode/extensions/ms-python.python-2020.1.58038/out/client/extension.js:1:86031)    at listOnTimeout (internal/timers.js:531:17)    at processTimers (internal/timers.js:475:7)]
t.log @ console.ts:137
2console.ts:137 [Extension Host] Notification handler 'textDocument/publishDiagnostics' failed with message: Cannot read property 'connected' of undefined
t.log @ console.ts:137
2console.ts:137 [Extension Host] (node:21707) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
t.log @ console.ts:137
$logExtensionHostMessage @ mainThreadConsole.ts:39
_doInvokeHandler @ rpcProtocol.ts:398
_invokeHandler @ rpcProtocol.ts:383
_receiveRequest @ rpcProtocol.ts:299
_receiveOneMessage @ rpcProtocol.ts:226
(anonymous) @ rpcProtocol.ts:101
fire @ event.ts:581
fire @ ipc.net.ts:453
_receiveMessage @ ipc.net.ts:733
(anonymous) @ ipc.net.ts:592
fire @ event.ts:581
acceptChunk @ ipc.net.ts:239
(anonymous) @ ipc.net.ts:200
t @ ipc.net.ts:28
emit @ events.js:200
addChunk @ _stream_readable.js:294
readableAddChunk @ _stream_readable.js:275
Readable.push @ _stream_readable.js:210
onStreamRead @ internal/stream_base_commons.js:166

output for python in output panel:

User belongs to experiment group 'AlwaysDisplayTestExplorer - control'
User belongs to experiment group 'ShowPlayIcon - start'
User belongs to experiment group 'ShowExtensionSurveyPrompt - enabled'
User belongs to experiment group 'DebugAdapterFactory - experiment'
User belongs to experiment group 'AA_testing - experiment'
> conda --version
> pyenv root
> python3.7 -c "import sys;print(sys.executable)"
> python3.6 -c "import sys;print(sys.executable)"
> python3 -c "import sys;print(sys.executable)"
> python2 -c "import sys;print(sys.executable)"
> python -c "import sys;print(sys.executable)"
> /usr/bin/python3.8 -c "import sys;print(sys.executable)"
> conda info --json
> conda env list
Starting Microsoft Python language server.
> conda --version
> /usr/bin/python3.8 ~/.vscode/extensions/ms-python.python-2020.1.58038/pythonFiles/interpreterInfo.py
> /usr/bin/python3.8 ~/.vscode/extensions/ms-python.python-2020.1.58038/pythonFiles/interpreterInfo.py

how to get the squiggle lines to work again?

Albric answered 14/1, 2020 at 18:12 Comment(4)
What are you using as your linter? Is it installed?Rattlebrain
@Boris i have the Microsoft python extension ms-python.python. it says it does linting, debugging etc. itselfAlbric
I have no clue, but it might help someone else if you post the output of the last two things they ask for here github.com/microsoft/vscode-python/issues/… Output for Python in the Output panel and Output from Console under the Developer Tools panelRattlebrain
@Boris I have added what you asked for. but i added only the error messages in the console in developer tools.Albric
A
11

In your settings.json file(search for settings.json in the command palette), declare the following:

"python.linting.pylintEnabled": true, "python.jediEnabled": false

if you just want the changes in your workspace then change the settings.json file in .vscode folder

In latest version of visual studio code, workspace is not registering settings from checkboxes so you have to explicitly declare in settings.json what settings you want to enable for your workspace. Flake8 is not affected by this. Pylint and Microsoft Python Language Server seem to be not working due to this.

side note:got this solution from sys-temd's reply on github.com/microsoft/vscode-python/issues

Albric answered 20/1, 2020 at 14:13 Comment(1)
The boolean JSON entries need to be lower case, i.e. "python.linting.pylintEnabled": trueAmourpropre
B
5

What I tried but not working

  1. pip install -U pylint
  2. declare "python.linting.pylintEnabled": true, "python.jediEnabled": false

Then I try to recreate a brand-new settings.json, pylint turns out working.

Therefore, I trace which line affects pylint.

In my case, it's the line beginning from "python.linting.pylintArgs":

Solution

Removing the line beginning from "python.linting.pylintArgs": will solve the problem.

Bun answered 12/7, 2021 at 17:34 Comment(2)
I was using flake8 and had this problem. I wanted to tell it what my max allowed line length is by passing it arguments from VSCode. However I got it wrong, it stopped complaining about line overruns but unknowingly to me, also stopped complaining about everything because it was dead and nothing told me!Triptych
This solved the problem for me! That's so odd! I wonder if I had a command line arg wrong?Tersanctus
J
0

Make sure in your settings you didn't turn off linting (and specifically Pylint if that's what you want to use). Also make sure you have Pylint installed and the Python extension knows where it is (either by creating an environment and installing into there or installing it globally and setting "python.linting.pylintPath"). Otherwise check the output of the "Python" channel in the Output Panel to see how Pylint is being executed and make sure that works when you copy-and-paste it into a terminal as appropriate.

Joshia answered 15/1, 2020 at 19:30 Comment(3)
python.linting.pylintPath is set to pylint. i tried $ which pylint it said "pylint not found". so i installed it with sudo apt-get install pylint it installed pylint and which pylint returned the path. but error-squiggle lines still not showing.(I reloaded vscode several times)Albric
Please specify the absolute path to pylint and not just the command name.Joshia
the issue got resolved i have posted the solution. had to add "python.linting.pylintEnabled":True in settings.json fileAlbric
U
0
pip install -U pylint

Solved my issue

Unsex answered 30/12, 2020 at 15:6 Comment(0)
E
0

If the main problem is those squiggle lines or some minor errors in the workspace then you can download the 'pylance extension' and enable it in settings of 'python language server'. This language server is even better (i think) because it is lighter than 'jedi' language server and also tells about the unused modules and variables or even the undefined variables as those squiggle lines show.

Emeryemesis answered 13/4, 2021 at 2:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.