Skip to content

Pylint not working when language server is on #7314

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
luabud opened this issue Sep 10, 2019 · 20 comments
Closed

Pylint not working when language server is on #7314

luabud opened this issue Sep 10, 2019 · 20 comments
Labels
area-intellisense LSP-related functionality: auto-complete, docstrings, navigation, refactoring, etc. bug Issue identified by VS Code Team member as probable bug verified Verification succeeded

Comments

@luabud
Copy link
Member

luabud commented Sep 10, 2019

Environment data

  • VS Code version: 1.38.0
  • Extension version (available under the Extensions sidebar): 2019.9.34911
  • OS and version: Windows 10
  • Python version (& distribution if applicable, e.g. Anaconda): 3.7.3
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): venv
  • Relevant/affected Python packages and their versions: pylint 2.3.1,
  • 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 #3977): Language Server

Expected behaviour

Having linting, pylint and LS enabled in user settings should provide linting messages from both pylint and the LS.

Actual behaviour

Only LS is displaying linting messages. In order to get pylint to work, the workaround is to explicitly enable it in the workspace settings.

Steps to reproduce:

Enable pylint in the user settings, and make sure linting and the LS are enabled.
Write a piece of code wrongly and notice that only the LS will display linting messages. We'd expect pylint to work as well.

cc @Anapo14

@luabud luabud added bug Issue identified by VS Code Team member as probable bug triage-needed Needs assignment to the proper sub-team area-intellisense LSP-related functionality: auto-complete, docstrings, navigation, refactoring, etc. needs PR labels Sep 10, 2019
@ghost ghost removed the triage-needed Needs assignment to the proper sub-team label Sep 10, 2019
@DonJayamanne DonJayamanne added triage-needed Needs assignment to the proper sub-team and removed needs PR labels Sep 11, 2019
@DonJayamanne
Copy link

DonJayamanne commented Sep 11, 2019

We'll need to triage this. If this is indeed a bug, then it's a regression and will need to be labeled accordingly.
Note, we'll need to identify the cause when triaging.

@kimadeline kimadeline self-assigned this Sep 11, 2019
@ghost ghost removed the triage-needed Needs assignment to the proper sub-team label Sep 11, 2019
@kimadeline
Copy link

If python.linting.pylintEnabled is not explicitly set (so we rely on the default value), the code will consider it disabled, see that comment in src/client/linters/linterInfo.ts:

// If we're using new LS, then by default Pylint is disabled (unless the user provides a value).

Why do we have this behaviour?

Double-checked, stepping through the code without having python.linting.pylintEnabled set anywhere (so it should default to true) returns false:

image

@kimadeline kimadeline removed their assignment Sep 13, 2019
@luabud
Copy link
Member Author

luabud commented Sep 16, 2019

If we're using new LS, then by default Pylint is disabled (unless the user provides a value).

this should flip the user setting for pylint to be disabled, instead of disregarding it.

@DonJayamanne
Copy link

this should flip the user setting for pylint to be disabled, instead of disregarding it.

Based on my recollection, this isn't what was requested.
However we can always change this.

@luabud
Copy link
Member Author

luabud commented Sep 16, 2019

The problem is that if pylint is enabled in the user setting, it shouldn't require users to explicitly set it on the workspace setting for it to work. So we should make that transparent by changing the user setting accordingly.

@DonJayamanne
Copy link

The problem is that if pylint is enabled in the user setting, it shouldn't require users to explicitly set it on the workspace setting for it to work

This is how it has always worked and was always the problem. Anyways, we can change this.

@darrickyee
Copy link

I am not sure what is meant by "this is how it has always worked"? As I understand it, the issue is that in the VSCode settings, the "Python > Linting: Pylint Enabled" checkbox is checked by default, but pylint is not actually enabled. So there is a discrepancy between what the Settings page shows and what the actual state of the settings is

Additionally, unchecking and re-checking the checkbox does not enable pylint (python.linting.pylintEnabled entry is deleted from settings.json when it is checked), so there is no way to enable pylint via the settings GUI. It seems the only way to enable it is to "manually" edit the settings.json file. I don't think this is what the behavior was in previous versions?

@luabud
Copy link
Member Author

luabud commented Sep 25, 2019

So there is a discrepancy between what the Settings page shows and what the actual state of the settings is

Yes, I agree with that.

Additionally, unchecking and re-checking the checkbox does not enable pylint (python.linting.pylintEnabled entry is deleted from settings.json when it is checked)

This is actually controlled by VS Code: microsoft/vscode#58038

@luabud luabud added the important Issue identified as high-priority label Oct 24, 2019
@marcinz
Copy link

marcinz commented Oct 24, 2019

This was reported before in #3292.

kbd added a commit to kbd/setup that referenced this issue Nov 23, 2019
Enabling Python Language Server seems to disable pylint?

microsoft/vscode-python#7314
@ghost
Copy link

ghost commented Jan 18, 2020

I am not sure what is meant by "this is how it has always worked"? As I understand it, the issue is that in the VSCode settings, the "Python > Linting: Pylint Enabled" checkbox is checked by default, but pylint is not actually enabled. So there is a discrepancy between what the Settings page shows and what the actual state of the settings is

Additionally, unchecking and re-checking the checkbox does not enable pylint (python.linting.pylintEnabled entry is deleted from settings.json when it is checked), so there is no way to enable pylint via the settings GUI. It seems the only way to enable it is to "manually" edit the settings.json file. I don't think this is what the behavior was in previous versions?

@darrickyee Same observations here. I reproduced your bug and the behaviour is same. Unless you declare your changes in .vscode > settings.json, checkbox is not registered by the extension.

E.g. - pylint is enabled in both user and workspace settings by default but I also have to declare

"python.pylintEnabled":true

in settings.json to enable pylint.

@WinstonN
Copy link

I am unable to get pylint to work in vscode

Version: 1.48.2
Commit: a0479759d6e9ea56afa657e454193f72aef85bd0
Date: 2020-08-25T10:09:08.021Z (4 days ago)
Electron: 7.3.2
Chrome: 78.0.3904.130
Node.js: 12.8.1
V8: 7.8.279.23-electron.0
OS: Darwin x64 18.7.0

My settings file looks like

❯❯❯ cat .vscode/settings.json
{
    "python.linting.enabled": true,
    "python.linting.pylintEnabled": true,
    "python.languageServer": "Jedi"
}

Running linting does nothing

image

Can you please help me get this working?
Thanks!

@WinstonN
Copy link

WinstonN commented Aug 30, 2020

Linting with bandit works

image

Pylint is installed, as can be seen

❯❯❯ python3 -m pip list |grep pylint
pylint             2.6.0

Language server enabled, using Microsoft

Settings file does not seem to reference correct application settings, not sure if this is another bug?

❯❯❯ cat .vscode/settings.json
{
  "python.linting.pylintEnabled": true,
  "python.linting.enabled": true,
  "python.linting.banditEnabled": false
}

@MaKaNu
Copy link

MaKaNu commented Sep 24, 2020

Okay I somehow understand the problem, but why is it a problem now? two or three updates before 1.49.1 I setted up my .pylintrc and everything work as intended. Why it stopped working after Updating?

@shadycuz
Copy link

shadycuz commented Mar 8, 2021

I seem to have the same problem but with flake8. Now sure I should open a new issue or not. For me it appears --format argument is misconfiged.

Here is what I get when I run the command that vscode is running :

~/.cache/pypoetry/virtualenvs/my-project-QvOwheDu-py3.9/bin/python ~/.vscode/extensions/ms-python.python-2021.2.582707922/pythonFiles/pyvsc-run-isolated.py flake8 src tests noxfile.py --format=%(row)d,%(col)d,%(code).1,%(code)s:%(text)s ~/repos/my-project/src/my_project/utils/system.py
bash: syntax error near unexpected token `('

@luabud
Copy link
Member Author

luabud commented Mar 8, 2021

@shadycuz I believe the syntax would be --format='%(row)d,%(col)d,%(code).1,%(code)s:%(text)s' (i.e. there are ' missing before and after the format pattern). At least that's what I see in the docs 😊

@shadycuz
Copy link

shadycuz commented Mar 9, 2021

@luabud that code is what visual studio code is running when I run the lint command. I don't see an error in the logs but I do see the command with no output. I'm not sure if the quotes are actually missing or if they were stripped because of weird log/shell stuff. I'll probably open my own issue.

@luabud
Copy link
Member Author

luabud commented Mar 9, 2021

Do you have any settings defined for flake8 on your settings.json? In any case please do open a separate issue 😊 it will be easier to investigate what is going on. Thanks!

@karthiknadig
Copy link
Member

Verified fixed in main.

@karthiknadig karthiknadig added this to the September 2021 milestone Sep 21, 2021
@karthiknadig karthiknadig added the verified Verification succeeded label Sep 21, 2021
@sanmai-NL
Copy link

@karthiknadig Can you show how a user can receive this fix? I do not see you reference a commit hash, release etc. The quoting issue still affects me on VS Code 1.61.1, inside an Alpine Linux dev container, with Python extension v2021.10.1336267007, based on the logs.

> /usr/local/bin/python -m bandit -f custom --msg-template {line},{col},{severity},{test_id}:{msg} -n -1 /srv/app/test.py
cwd: /srv/app
> /usr/local/bin/python -m flake8 --format=%(row)d,%(col)d,%(code).1s,%(code)s:%(text)s /srv/app/test.py
cwd: /srv/app
> /usr/local/bin/python -m pylint --msg-template='{line},{column},{category},{symbol}:{msg} --reports=n --output-format=text /srv/app/test.py
cwd: /srv/app

@karthiknadig
Copy link
Member

@sanmai-NL this issue is about language server and pylint, not really about the results from pylint. You may need to file a separate issue for that. Previously, we only had either linter messages or messages for LS (because we did not run pylint at all if LS was enabled). With this change, if both linter and ls are enabled you get messages for both. The change itself is not referred here directly because this issue was a side effect of how we were handling linting.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 29, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-intellisense LSP-related functionality: auto-complete, docstrings, navigation, refactoring, etc. bug Issue identified by VS Code Team member as probable bug verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

10 participants