Skip to content
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

pylint checks with pylance enabled #13315

Closed
yankyhoffman opened this issue Jul 1, 2020 · 20 comments
Closed

pylint checks with pylance enabled #13315

yankyhoffman opened this issue Jul 1, 2020 · 20 comments
Labels
area-linting bug Issue identified by VS Code Team member as probable bug

Comments

@yankyhoffman
Copy link

Dunno if this should be a bug report or feature request...

First of all, I just installed and used pylance as the language server for my vscode and it is indeed SUPER! thanks.

However, I had setup plenty of custom python.linting.pylintArgs to check in my code, for example on my most occuring bugs are trailing-comma-tuple and more, after switching python.languageServer to "Pylance" these checks stopped being checked for.

As said, I would consider this a feature request that pylance should support these checks.

Another example is, unused variables, in pylint I got unused variables error for unused arguments in function signatures, while pylance only checks for code blocks, i.e.;

def function(a, b):
    c = 42
    return a

pylint would complain about b and c being unused, while pylance only complains about c.

Once again, super cool linter!

@gramster
Copy link
Member

gramster commented Jul 1, 2020

Can you check your 'PyLint enabled' setting? Maybe you just need to re-enable it.

@yankyhoffman
Copy link
Author

Yes, I checked, and it is explicitly set to true.

@jakebailey
Copy link
Member

Interesting; I would have assumed it was just being disabled by default by the extension. For reference, the extension uses pylint by default (in conjunction with other tools) to provide at least some info like syntax checks without a language server, so I can see why it may disable that tooling if an LS is there to do "live linting" (among everything else an LS does).

@yankyhoffman
Copy link
Author

yankyhoffman commented Jul 1, 2020

That is exactly why I came here, to open a bug report.

I love vscode along with the python extension, and now we got pylance which is super as well!

The least I can do is give some testing help...

@gramster
Copy link
Member

gramster commented Jul 1, 2020

It looks like pylint only runs when LS is set to Jedi. It doesn't run LS set to with MPLS or pylance. There is some risk of clobbering here but it seems we should still run the linter, especially if we have listing on save set.

@MikhailArkhipov
Copy link

This looks like a bug, LS activation does turn off linter by default but explicit setting should work. This may need to get ported to https://github.com/Microsoft/vscode-python

@jakebailey jakebailey transferred this issue from microsoft/pylance-release Aug 6, 2020
@ghost ghost added the triage-needed Needs assignment to the proper sub-team label Aug 6, 2020
@jakebailey
Copy link
Member

Transferred; AFAIK it's a behavior change in the extension to allow pylint to run while an LS is active.

@ewerybody
Copy link

It looks like pylint only runs when LS is set to Jedi. It doesn't run LS set to with MPLS or pylance. There is some risk of clobbering here but it seems we should still run the linter, especially if we have listing on save set.

I just want to confirm: I got pylint working again with all my settings with Jedi on Pyton 3.8.5 so far I didn't manage to make it work on my 2.7.18 project :/ But I got some console output working. It's in the Output-tab unter "Python"...

@karthiknadig karthiknadig added investigating We are looking into the cause of the issue and removed triage labels Sep 15, 2020
@mcosta74
Copy link

Any news about it ??
also trying to set LS to Jedi didn't solved the issue

vscode version: 1.49.1
Python 3.7.7

@petterssonandreas
Copy link

petterssonandreas commented Oct 1, 2020

I found out about pylance just a couple of days ago and enabled it. It is very nice, but I too lost all my linting from pylint. I found this issue after searching for a solution.

After some more trial, I seem to have been able to re-enable pylint without changing the language server (i.e. I get both pylance and pylint warnings). I did this by explicitly enabling pylint in my settings.json file. So my settings.json now include, among other lines:

    "python.linting.pylintEnabled": true,
    "python.languageServer": "Pylance",

I had to make the change manually in settings.json, just checking the setting "Python > Linting: Pylint Enabled" in the graphical settings meny in VSCode was not enough (that was marked as enabled the whole time). Why this works I don't really know, but it seems to work for me at least. Also, the order of the lines in settings.json doesn't seem to matter. I have tried this on both a Linux and a Windows machine.

I hope this can help someone else.

Windows machine config:
VSCode: 1.49.2
Python: 3.8.5
Pylint: 2.6.0
Python extension: 2020.9.112786
Pylance extension: 2020.9.7

@mcosta74
Copy link

mcosta74 commented Oct 1, 2020

A small update.

Looks like the problem is only for Workspace with multiple folders.

workspace-dir
    |
    + <filename>.code-workspace
    |
    + python directory
    |
    + other directories ...

@petterssonandreas
Copy link

A small update.

Looks like the problem is only for Workspace with multiple folders.

Hmm, I have seen this issue in a workspace with only a single python file in the root of the workspace, and no other files or directories. I also got the same issue when opening a python file without a workspace. My solution by manually updating the User settings.json worked for both.

@ghost
Copy link

ghost commented Nov 4, 2020

I found out about pylance just a couple of days ago and enabled it. It is very nice, but I too lost all my linting from pylint. I found this issue after searching for a solution.

After some more trial, I seem to have been able to re-enable pylint without changing the language server (i.e. I get both pylance and pylint warnings). I did this by explicitly enabling pylint in my settings.json file. So my settings.json now include, among other lines:

    "python.linting.pylintEnabled": true,
    "python.languageServer": "Pylance",

I had to make the change manually in settings.json, just checking the setting "Python > Linting: Pylint Enabled" in the graphical settings meny in VSCode was not enough (that was marked as enabled the whole time). Why this works I don't really know, but it seems to work for me at least. Also, the order of the lines in settings.json doesn't seem to matter. I have tried this on both a Linux and a Windows machine.

I hope this can help someone else.

Windows machine config:
VSCode: 1.49.2
Python: 3.8.5
Pylint: 2.6.0
Python extension: 2020.9.112786
Pylance extension: 2020.9.7

works for me also.

@dshemetov
Copy link

I found out about pylance just a couple of days ago and enabled it. It is very nice, but I too lost all my linting from pylint. I found this issue after searching for a solution.

After some more trial, I seem to have been able to re-enable pylint without changing the language server (i.e. I get both pylance and pylint warnings). I did this by explicitly enabling pylint in my settings.json file. So my settings.json now include, among other lines:

    "python.linting.pylintEnabled": true,
    "python.languageServer": "Pylance",

I had to make the change manually in settings.json, just checking the setting "Python > Linting: Pylint Enabled" in the graphical settings meny in VSCode was not enough (that was marked as enabled the whole time). Why this works I don't really know, but it seems to work for me at least. Also, the order of the lines in settings.json doesn't seem to matter. I have tried this on both a Linux and a Windows machine.

I hope this can help someone else.

Windows machine config:
VSCode: 1.49.2
Python: 3.8.5
Pylint: 2.6.0
Python extension: 2020.9.112786
Pylance extension: 2020.9.7

Solved for me on WSL, VSCode v1.50, Pylance v2020.11.0, Python ext v2020.10.332292344

@mcosta74
Copy link

mcosta74 commented Nov 6, 2020

Does this trick work also with workspace (multi-language) projects?

@petterssonandreas
Copy link

Does this trick work also with workspace (multi-language) projects?

Yes, manually modifying my User settings.json file works for me in a very large workspace with multiple languages present in both shared and seperate folders (if that was what you meant by your question).

However, I noticed now when I tried some more, that if I open only a single file on Linux/Ubuntu with code path/to/file I did not get pylint warnings, so maybe I have some other hidden config or problem still? But it does work on my Windows machine (where I have a cleaner setup) so maybe it is just a config difference. But workspaces, both small and large, work with pylint on both of my machines.

@astrelsky
Copy link

astrelsky commented Jul 11, 2021

This is still a problem. Pylance does almost no linting in comparison to pylint. The linter enabled in the settings should not be silently disabled when enabled in the settings via the user interface. I have yet to try explicitly setting it in the json settings but it shouldn't be necessary.

If I could use pylance and vscode at work and not get hounded during code review for code formatting issues that the linter would have caught, that'd be great.

@webmaniak
Copy link

webmaniak commented Jul 22, 2021

I could not agree more with @astrelsky. I too am in charge of code reviews and try to manage the general configuration for my fellow developers, and this issue is bugging me even more since Pylance has become the default language server in VSCode. I really love that environment, but currently it's really hard for me to enforce code quality without pylint.

My configuration currently is as follow:

User's settings.json:

"python.linting.enabled": true,
"python.linting.pylintEnabled": true,
"python.languageServer": "Pylance"

Workspace's settings.json:

"python.linting.enabled": true,
"python.linting.pylintEnabled": true,
"python.linting.pylintUseMinimalCheckers": false,
"python.linting.pylintArgs": [
    "--load-plugins=pylint_django",
]

And although everything has been explicitely enabled and my venvs are active, I just can't get a single input from pylint. The "problems" console remains oddly quiet, and I know the codebase is not as clean as that. This is frustrating. Not only linter settings must not be silenced, but we should be able to choose whether we want Pylance or any other linter to assist developers achieving appropriate code quality.

@petterssonandreas
Copy link

petterssonandreas commented Jul 23, 2021

And although everything has been explicitely enabled and my venvs are active, I just can't get a single input from pylint. The "problems" console remains oddly quiet, and I know the codebase is not as clean as that. This is frustrating. Not only linter settings must not be silenced, but we should be able to choose whether we want Pylance or any other linter to assist developers achieving appropriate code quality.

I tried your config on my Windows machine, with Python 3.9.6, VSCode 1.58.2, Pylance 2021.7.5, Python extension 2021.7.1053846006, pylint 2.9.5. In a simple workspace I get both pylance and pylint warnings as I expect them.

So I don't know if your user/workspace settings actually is what you specified? Also I don't really know how/what you mean by "my venvs are active", but I wouldn't think that would be important, unless you don't have pylint installed in your virtual environment and that fails silently in VSCode somehow?

But, yes, I agree that this is a big problem, Pylance should not force you to manually enable pylint in the .json settings file.

@karrtikr karrtikr added needs PR Ready to be worked on and removed needs PR Ready to be worked on labels Aug 9, 2022
@karthiknadig karthiknadig added triage-needed Needs assignment to the proper sub-team and removed investigating We are looking into the cause of the issue labels Mar 3, 2023
@karthiknadig karthiknadig added needs proposal Need to make some design decisions bug Issue identified by VS Code Team member as probable bug and removed triage-needed Needs assignment to the proper sub-team labels Jul 12, 2023
@karthiknadig karthiknadig removed their assignment Jul 12, 2023
@luabud
Copy link
Member

luabud commented Oct 31, 2023

We have deprecated the built-in support for Pylint in favour of the Pylint extesion. Pylint can now work side by side with Pylance by default once you install the extension (it actually ships with a version of pylint so you don't even need to install pylint in your environment for it to work either if you don't want to!)

Keep in mind that some diagnostics displayed in Pylint won't be displayed in Pylance given Pylint also triggers stylistic warnings which Pylance does not. I'm closing this issue but if you have suggestions or feedback on Pylance's diagnostics feel free to file an issue at https://github.com/microsoft/pylance-release 😊

@luabud luabud closed this as completed Oct 31, 2023
@github-actions github-actions bot removed the needs proposal Need to make some design decisions label Oct 31, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 1, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-linting bug Issue identified by VS Code Team member as probable bug
Projects
None yet
Development

No branches or pull requests