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 not working when using Python Language Server #3292

Closed
josherickson opened this issue Nov 10, 2018 · 4 comments
Closed

Pylint not working when using Python Language Server #3292

josherickson opened this issue Nov 10, 2018 · 4 comments
Assignees

Comments

@josherickson
Copy link

Environment data

  • VS Code version: 1.28.2
  • Extension version (available under the Extensions sidebar): 2018.10.1
  • OS and version: macOS Mojave 10.14.1
  • Python version (& distribution if applicable, e.g. Anaconda): Python 3.7.0
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): N/A
  • Relevant/affected Python packages and their versions: pylint 2.1.1

Actual behavior

When "python.jediEnabled": true is set in User Settings, pylint runs as expected. I see a "Missing module docstring" under the Problems window, and I see the following in the Output (Python) window:

##########Linting Output - pylint##########
************* Module test
1,0,convention,C0111:Missing module docstring

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

Switch to "python.jediEnabled": false in User Settings and pylint does not run. I see no Problems listed, and the only Output is:

Starting Microsoft Python language server.
Microsoft Python Language Server version 0.1.60.0
Initializing for /usr/local/bin/python3

Expected behavior

Pylint should run in both cases, which would be indicated by the same Problem list and pylint messages in the Output window.

Steps to reproduce:

  1. Create a file test.py that contains a single line A = 1 + 2.
  2. In your User settings, have:
"python.jediEnabled": true,
"python.linting.lintOnSave": true,
"python.linting.enabled": true,
"python.linting.pylintEnabled": true,
  1. You should see the Pylint warning for a missing module docstring.
  2. Disable Jedi by changing the setting to "python.jediEnabled": false,. The other settings should remain the same. You will have to reload the the window.
  3. You should no longer see the Pylint warning, as described above.
  4. Shift + ⌘ + P -> Python: Select Linter and it should say current: none.
  5. Select a different linter, like pep8. You will be prompted that "Linter pep8 is not installed". You can close that, no need to install for this.
  6. Shift + ⌘ + P -> Python: Select Linter and it now says current: pep8.
  7. Select pylint this time. Nothing appears to happen.
  8. Shift + ⌘ + P -> Python: Select Linter and it now says current: none.
  9. Linting with pylint still not working.

Note: I have had pylint working when "python.jediEnabled": false in the past. I have uninstalled and reinstalled pylint and python a number of times over the past couple weeks for unrelated reasons. I do not know if this was the cause of the current issue, or if they are unrelated. Python and pylint are currently installed as I test and write this.

Logs

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

Starting Microsoft Python language server.
Microsoft Python Language Server version 0.1.60.0
Initializing for /usr/local/bin/python3

Linter 'pep8' is not installed. Please install it or select another linter".
Error: Module 'pep8' not installed.

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

[Extension Host] Python Extension: All locators have completed locating, , Return Value: 
[Extension Host] Python Extension: Checking whether locactors have completed locating, , Return Value: 
[Extension Host] Python Extension: Linter 'pep8' is not installed. Please install it or select another linter". Error: Module 'pep8' not installed.
	at PythonExecutionService.<anonymous> (/Users/josh/.vscode/extensions/ms-python.python-2018.10.1/out/client/common/process/pythonProcess.js:106:27)
	at Generator.next (<anonymous>)
	at fulfilled (/Users/josh/.vscode/extensions/ms-python.python-2018.10.1/out/client/common/process/pythonProcess.js:12:58)
	at <anonymous>
Linter pep8 is not installed.
@brettcannon brettcannon self-assigned this Nov 13, 2018
@brettcannon
Copy link
Member

I can't reproduce:

image

This is the same result regardless of what "python.jediEnabled" is set to.

Do note that our default Pylint settings do not warn about missing a module docstring. Add an empty .pylintrc file to cause our default Pytlint settings to be ignored.

@josherickson
Copy link
Author

@brettcannon Good to know, I was testing this issue within a workspace where I already had a .pylintrc file. Here are a couple screen recordings of an isolated test.

My user settings contain the following:

{
    "python.pythonPath": "/usr/local/bin/python3",
    "python.linting.enabled": true,
    "python.linting.pylintEnabled": true,
    "python.jediEnabled": true
}

In this first recording, pylint has already ran with Jedi enabled. I disable Jedi and pylint will not run. I re-enable Jedi and pylint runs again (as soon as I change to true, and then again on window reload). I then close the file to end the gif.
capture-1

Prior to this second recording, I have saved the folder as a workspace with the default .code-workspace file (not shown). Jedi is disabled throughout the recording. I attempt to select pylint as the linter twice (the first time creates folder settings), but both times the selection remains "none" as seen in the clip, and pylint does not run.
capture-2

Hope this information helps, I know these things can be a nightmare to diagnose and reproduce.

@brettcannon
Copy link
Member

Still can't reproduce on either Windows 10 or macOS Mojave w/ a VS Code 1.29.0 and 2018.10.1 of the extension:

image

This is using:

def f():
    try:
        unused = 1 / 0
    except Exception:
        return False
        print("never")

And this is in a clean directory and virtual environment that wasn't polluted with anything.

Best I can think of is checked under Developer Tools to see if that provides any useful information.

@josherickson
Copy link
Author

@brettcannon Doesn't appear to be much useful information in the Developer Tools console, and I did a complete reinstall of VS Code.

Looks like the issue I'm having is either the same or related to this one here: #3351

If I start where I left off in my previous post with the following settings:

User Settings

"python.jediEnabled": false,
"python.linting.lintOnSave": true,
"python.linting.enabled": true,
"python.linting.pylintEnabled": true,
"python.pythonPath": "/usr/local/bin/python3" // Because I have P2 and P3 installations.

Workspace Settings

{
	"folders": [
		{
			"path": "."
		}
	],
	"settings": {
	}
}

Folder Settings

{
    "python.linting.pylintEnabled": true,
    "python.linting.enabled": true
}

I currently get no linting. However, if I add "python.linting.pylintEnabled": true, to Workspace settings, then I get linting (this is with Jedi disabled).

@lock lock bot locked as resolved and limited conversation to collaborators Dec 13, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants