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

Linting reports incorrect file locations for lint errors / warnings #7020

Closed
rvinzent opened this issue Aug 19, 2019 · 8 comments
Closed

Linting reports incorrect file locations for lint errors / warnings #7020

rvinzent opened this issue Aug 19, 2019 · 8 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug info-needed Issue requires more information from poster

Comments

@rvinzent
Copy link

Environment data

VSCode

Version: 1.37.1
Commit: f06011ac164ae4dc8e753a3fe7f9549844d15e35
Date: 2019-08-15T16:16:34.800Z
Electron: 4.2.7
Chrome: 69.0.3497.128
Node.js: 10.11.0
V8: 6.9.427.31-electron.0
OS: Darwin x64 18.7.0
  • Extension version: 2019.8.30787
  • Python version: 2.7
  • Type of virtual environment used: virtualenv
  • Relevant/affected Python packages and their versions: flake8 v3.7.7
  • Jedi or Language Server: Microsoft Language Server
  • Using a multi-root workspace (I have had a ton of problems with multiroot workspaces so it may be relevant)

Expected behaviour

I expect the Problems tab to point to correct locations. I expect red underlines to appear where the linting errors are reported.

Actual behaviour

Red underlines appear in any open file when any lint errors are reported. Correct locations of linting failures are not shown. The below screenshot shows the line import random underlined as red for the incorrect error. Every lint error is highlighted in every open file making it impossible to determine the actual location of the errors.

Screen Shot 2019-08-19 at 8 43 32 AM

Logs

(truncated to remove proprietary code)

##########Linting Output - flake8##########
7,1,F,F401:'hamcrest.is_in' imported but unused
1,1,F,F401:'datetime.datetime' imported but unused
4,1,F,F401:'arrow' imported but unused
1162,1,E,E305:expected 2 blank lines after class or function definition, found 1
1165,37,F,F821:undefined name 'AuthenticatedTestCase'

Output from Console under the Developer Tools panel (toggle Developer Tools on under Help; turn on source maps to make any tracebacks be useful by running Enable source map support for extension debugging)

Duplicate logs removed, paths changed

console.ts:137 [Extension Host] Info Python Extension: 2019-08-19 08:18:29: Cached data exists getEnvironmentVariables, /Users/rvinzent/repo
console.ts:137 [Extension Host] Info Python Extension: 2019-08-19 08:18:33: Cached data exists getEnvironmentVariables, /Users/rvinzent/repo
console.ts:137 [Extension Host] Info Python Extension: 2019-08-19 08:19:10: Cached data exists getEnvironmentVariables, /Users/rvinzent/repo
console.ts:137 [Extension Host] 2019-08-19T15:19:15.464Z - debug: [ImportOrganizer] OrganizeOnSave is deactivated through config
exists getEnvironmentVariables, /Users/rvinzent/repo
ms-python.gallerycdn…dio.Code.Manifest:1 Failed to load resource: the server responded with a status of 404 ()
console.ts:137 [Extension Host] Info Python Extension: 2019-08-19 08:25:59: Cached data exists getEnvironmentVariables, extension-output-#9
ms-python.gallery.vs…dio.Code.Manifest:1 Failed to load resource: the server responded with a status of 503 ()
log.ts:173   ERR Unexpected end of JSON input: SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at Object.<anonymous> (file:///Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:1626:627)
    at Generator.next (<anonymous>)
    at r (file:///Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:35:293)
console.ts:137 [Extension Host] 2019-08-19T15:30:18.990Z - debug: [ImportOrganizer] OrganizeOnSave is deactivated through config
console.ts:137 [Extension Host] Info Python Extension: 2019-08-19 08:30:19: Cached data exists getEnvironmentVariables, /Users/rvinzent/repo/workspace/path/to/file.py
console.ts:137 [Extension Host] Info Python Extension: 2019-08-19 08:41:37: Cached data exists getEnvironmentVariables, /Users/rvinzent/repo/.vscode/repo.code-workspace
console.ts:137 [Extension Host] Info Python Extension: 2019-08-19 08:41:42: Cached data exists getEnvironmentVariables, /Users/rvinzent/repo
console.ts:137 [Extension Host] Info Python Extension: 2019-08-19 08:41:53: Cached data exists getEnvironmentVariables, /Users/rvinzent/repo
console.ts:137 [Extension Host] Info Python Extension: 2019-08-19 08:43:01: Cached data exists getEnvironmentVariables, /Users/rvinzent/repo
console.ts:137 [Extension Host] Info Python Extension: 2019-08-19 08:50:03: Cached data exists getEnvironmentVariables, extension-output-#2
@rvinzent rvinzent added triage-needed Needs assignment to the proper sub-team bug Issue identified by VS Code Team member as probable bug labels Aug 19, 2019
@karrtikr karrtikr self-assigned this Aug 19, 2019
@ghost ghost removed the triage-needed Needs assignment to the proper sub-team label Aug 19, 2019
@karrtikr
Copy link

Can you please paste the file content? Unfortunately, I am not able to reproduce this just with any file.

##########Linting Output - flake8##########
7,1,F,F401:'hamcrest.is_in' imported but unused
1,1,F,F401:'datetime.datetime' imported but unused
4,1,F,F401:'arrow' imported but unused
1162,1,E,E305:expected 2 blank lines after class or function definition, found 1
1165,37,F,F821:undefined name 'AuthenticatedTestCase'

Are the line numbers and column numbers reported in the output correct?

@karrtikr karrtikr added the info-needed Issue requires more information from poster label Aug 19, 2019
@rvinzent
Copy link
Author

rvinzent commented Aug 20, 2019

@karrtikr Unfortunately I won't be able to post a full file, and to be honest I don't know how useful a single file will be. The issue occurs in all open files regardless of whether or not an actual linting violation exists in that file. I haven't had the time to reproduce a minimal repo, but I would really like to see this fixed so I will do my best if we are still unable to pinpoint the issue. Here is some more info to help track down:

  • the line and char no in the flake8 output is correct and there is a single report for each violation
  • Running via command line produces expected results
  • my flake8 config is in a tox.ini file in the top level directory
  • every lint violation is highlighted in every open editor, everything else appears to be working properly
  • when the file with the lint violation is open, VSCode correctly highlights the issue, but it's impossible to tell which file is causing the problem
  • the warnings also appear to ignore noqa comments even though the raw output doesn't report them.

Screen Shot 2019-08-20 at 9 09 01 AM

Note: this appears to be caused by the default python linting in vscode. Not sure why the default is running when I have another linter enabled.

tox.ini

[flake8]
max_line_length = 122
ignore = E722 W503
exclude =
    ve
    node_modules

settings.json

    "python.pythonPath": "env/bin/python",
    "python.jediEnabled": false,
    "python.linting.flake8Enabled": true,
    "python.linting.flake8Args": [
        "fabfile",
        "lib_project",
        "scripts",
        "tests",
        "project"
    ],

Here's another screenshot of a 4 line file I created to demonstrate. This was the only function in the file the other being the import. VSCode highlights lint violations originating from multiple other files.

Screen Shot 2019-08-20 at 8 54 12 AM

@rvinzent
Copy link
Author

@karrtikr Might be related to #4074

@karrtikr
Copy link

karrtikr commented Aug 24, 2019

Note: this appears to be caused by the default python linting in vscode. Not sure why the default is running when I have another linter enabled.

Python Language server Intellisense provider also provides linting. It's because of setting "python.jediEnabled": false.
You can remove that setting or turn it to true to switch to Jedi Intellisense. Let me know how that goes.

Btw do linters other that flake8 work fine?

@rvinzent
Copy link
Author

It appears to be only flake8. pylint with python.jediEnabled: true seems to work fine

@karrtikr
Copy link

I expect with python.jediEnabled set to true, you should be getting any other linting other than flake8.

As I am not able to reproduce this, it's hard to pin point the issue, so I have to close this issue for now. If you can come up with a reproducible case, I'll happy to reopen the issue and work on this.

@ghost ghost removed the triage label Aug 26, 2019
@rvinzent
Copy link
Author

rvinzent commented Aug 27, 2019

@karrtikr the jedi server doesn't work well for me. I would rather use the Microsoft Language Server with the linting disabled. Is this possible? I'll also try to find the time to produce a minimal repo highlighting the issue with flake8.

@karrtikr
Copy link

You can always disable linting (from command palette) and use Microsoft language server.

@lock lock bot locked as resolved and limited conversation to collaborators Sep 3, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug info-needed Issue requires more information from poster
Projects
None yet
Development

No branches or pull requests

2 participants