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 in VSCode showing different output from running pylint in command line #728

Closed
aniforprez opened this issue Feb 8, 2018 · 9 comments
Assignees
Labels
area-linting bug Issue identified by VS Code Team member as probable bug
Milestone

Comments

@aniforprez
Copy link

aniforprez commented Feb 8, 2018

Environment data

VS Code version: 1.20.0
Python Extension version: 2018.1.0
Python Version: 2.7.10
OS and version: macOS High Sierra 10.13.3

Actual behavior

Errors being thrown by pylint in the extension differ greatly from those in the output of running pylint in the command line.

  • pylint in the command line uses current working environment to resolve imports from installed packages. Extension does not and is unable to import packages in the environment
  • pylint ignores print statements since installed python version is < 3. Extension throws errors at these statements

Most importantly, the extension was working FINE until the recent VSCode update

Expected behavior

Extension should follow be able to import packages installed in local environment, use local python version, have same output as pylint when run in command line and return to working as before

Steps to reproduce:

No clue

Logs

Output from Python output panel

##########Linting Output - pylint##########
************* Module pptgen.pptprocessor
7,0,error,E0401:Unable to import 'pptx'
8,0,error,E0401:Unable to import 'pptx.dml.color'
9,0,error,E0401:Unable to import 'pptx.util'
56,8,error,E1601:print statement used

------------------------------------------------------------------
Your code has been rated at 7.47/10 (previous run: 9.75/10, -2.28)

Output from Console window (Help->Developer Tools menu)

[Extension Host] Python Extension: Failed to get conda info from conda null
t.log @ /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:253
@DonJayamanne
Copy link

DonJayamanne commented Feb 8, 2018

  1. Please could you let me know what python interpreter has been selected in your workspace?
    Look at the bottom status bar on the left, check the tooltip to determine the parth.
    Next check whether pptx is installed in that environment.

  2. The issue with the print statement is tracked in print statement is highlighted by pylint #722

@DonJayamanne DonJayamanne added bug Issue identified by VS Code Team member as probable bug area-linting info-needed Issue requires more information from poster labels Feb 8, 2018
@aniforprez
Copy link
Author

aniforprez commented Feb 8, 2018

The selected interpreter is Python 2.7.10 (ppt-builder). python-pptx is definitely installed. But it's not just that. I'm using rest framework in another file and that is shown as an error too.

@DonJayamanne
Copy link

  • Please could you provide the value from python.pythonPath setting in your workspace setting?
  • Next, please copy the above settng into your terminal window
    xxxx/bin/python -m pylint <filename>

@robhaswell
Copy link

robhaswell commented Feb 15, 2018

I have the same error and I have a theory about why. I think the $CWD of the pylint process is now the parent directory of the target file, instead of the workspace root:

$
(venv) cloudfind@spirit:~/Projects/muon (master)
$ pylint muon/services/postgres.py

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

(venv) cloudfind@spirit:~/Projects/muon (master)
$ cd muon/services/
(venv) cloudfind@spirit:~/Projects/muon/muon/services (master)
$ pylint postgres.py
No config file found, using default configuration
************* Module postgres
E:  9, 0: Attempted relative import beyond top-level package (relative-beyond-top-level)
C: 11, 0: Invalid constant name "log" (invalid-name)

-------------------------------------------------------------------
Your code has been rated at 8.75/10 (previous run: 10.00/10, -1.25)

(venv) cloudfind@spirit:~/Projects/muon/muon/services (master)
$

This matches up with the VS Code output which is:

##########Linting Output - pylint##########
************* Module postgres
9,0,error,E0402:Attempted relative import beyond top-level package

------------------------------------------------------------------
Your code has been rated at 8.96/10 (previous run: 9.79/10, -0.83)

The only discrepancy is that VS Code is not complaining about the log constant name, this makes me think that the .pylintrc for this workspace is being loaded somehow. It would be helpful to be able to see the exactly pylint command being executed.

@MikhailArkhipov
Copy link

Please see discussion in #722

@MikhailArkhipov MikhailArkhipov self-assigned this Feb 15, 2018
@aniforprez
Copy link
Author

@DonJayamanne

Sorry for the late response.

"python.pythonPath": "/Users/anirudhs/.virtualenvs/ppt-builder/bin/python"

Running the command
/Users/anirudhs/.virtualenvs/ppt-builder/bin/python -m pylint core/apis.py
gives me the output
/Users/anirudhs/.virtualenvs/ppt-builder/bin/python: No module named pylint

@aniforprez
Copy link
Author

aniforprez commented Feb 17, 2018

I'd also like to add that it is COMPLETELY ignoring my .pylintrc file which resides in my home directory as ~/.pylintrc. This used to work but now doesn't though it is apparently being tracked at #788

@MikhailArkhipov
Copy link

Looks like duplicate of #788
You can set pyLintUseMinimalCheckers to false as a workaround

@MikhailArkhipov MikhailArkhipov added this to the February 2018 milestone Feb 17, 2018
@MikhailArkhipov MikhailArkhipov added awaiting 2-PR and removed info-needed Issue requires more information from poster labels Feb 17, 2018
@MikhailArkhipov
Copy link

d44386e

@lock lock bot locked as resolved and limited conversation to collaborators Jul 12, 2018
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

4 participants