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

Prospector gets file paths wrong #199

Closed
DonJayamanne opened this issue Nov 14, 2017 · 8 comments · Fixed by #1155
Closed

Prospector gets file paths wrong #199

DonJayamanne opened this issue Nov 14, 2017 · 8 comments · Fixed by #1155
Assignees
Labels
area-linting bug Issue identified by VS Code Team member as probable bug
Milestone

Comments

@DonJayamanne
Copy link

From @zersiax on October 9, 2017 22:17

Environment data

VS Code version: Latest Insider as of now
Python Extension version: Latest version available in Marketplace
Python Version: 3.6
OS and version: Windows 10 build 16299

Actual behavior

In my problems view, I'm seeing errors about "no module named" followed by the path to the current file I'm in, e.g., c:\users\name\project\app\views.py). However, this code runs fine using the same Python context and gives no such errors.

Expected behavior

I shouldn't see these errors since they aren't errors.

Steps to reproduce:

  • (going to list everything I did, not sure what parts are relevant)
  1. Create a new Django project in the home folder of WSL (Windows Subsystem for Linux).
  2. Realize you can't reach that filesystem from Vs Code and copy the folder to your Windows home folder, e.g. c:\users\name\dev.
  3. Open the project in Visual Studio Code. Note that we're not using a virtual environment. One was created, but in WSL so it would be Linux-based and probably not useful to the Windows host. It is, however, present in the copied folder in my case, although it is not being used. Autopep8, prospector and Django 1.11 are installed to the global context using pip.
  4. Open any given file, settings.py is fine.
  5. At this point, I am already getting this error by Prospector about no module name ....../settings.py.
  6. I tried feeding --uses django into the ProspectorArgs array in settings.json but this didn't fix the issue.

Copied from original issue: DonJayamanne/pythonVSCode#1289

@DonJayamanne
Copy link
Author

Unfortulately WSL isn't supported at this stage.
https://github.com/DonJayamanne/pythonVSCode/issues/534

@DonJayamanne
Copy link
Author

Hopefully this will be resolved soon. Please follow the #534 for updates.

@DonJayamanne
Copy link
Author

From @zersiax on October 10, 2017 10:9

@DonJayamanne From step 2 in my reproduce steps, WSL is completely out of the picture, so I don't think this is a WSL issue?

@DonJayamanne
Copy link
Author

What's the path to your python virtual environment?
Please ensure this is configured in your workspace settings (settings.json), i.e. the setting python.pythonPath needs to point to the python interpreter you are working on.

@DonJayamanne
Copy link
Author

From @zersiax on October 10, 2017 18:29

Python I'm working on is my Windows OS's global python install, which is added to the OS PATH environment variable. Wouldn't the extension pick it up at that point?

@DonJayamanne
Copy link
Author

Yes it would.

@brettcannon brettcannon added awaiting 1-verification area-linting bug Issue identified by VS Code Team member as probable bug labels Nov 14, 2017
@DonJayamanne DonJayamanne self-assigned this Jan 11, 2018
@brettcannon brettcannon changed the title Extension with Prospector linting gives false positives Prospector gets file paths wrong Jan 11, 2018
@brettcannon
Copy link
Member

For some reason Prospector is passing into Pylint the file's path with the directory structured duplicated, e.g. c:\a\b\c\d.py as c:\a\b\c\a\b\c\d.py.
Output:

#######Linting Output - prospector##########
{
  "summary": {
    "started": "2018-01-11 14:55:40.524661",
    "libraries": [],
    "strictness": null,
    "profiles": "default, no_doc_warnings, no_test_warnings, strictness_medium, strictness_high, strictness_veryhigh, no_member_warnings",
    "tools": [
      "dodgy",
      "mccabe",
      "pep8",
      "profile-validator",
      "pyflakes",
      "pylint"
    ],
    "message_count": 2,
    "completed": "2018-01-11 14:55:41.418668",
    "time_taken": "0.89",
    "formatter": "json"
  },
  "messages": [
    {
      "source": "pylint",
      "code": "syntax-error",
      "location": {
        "path": "c:\\Users\\brcan\\Desktop\\bunk\\tester.py",
        "module": "tester",
        "function": null,
        "line": 5,
        "character": 0
      },
      "message": "invalid syntax (<string>, line 5)"
    },
    {
      "source": "pylint",
      "code": "fatal",
      "location": {
        "path": "c:\\Users\\brcan\\Desktop\\bunk\\Users\\brcan\\Desktop\\bunk\\tester.py",
        "module": "c:\\Users\\brcan\\Desktop\\bunk\\Users\\brcan\\Desktop\\bunk\\tester.py",
        "function": null,
        "line": 1,
        "character": 0
      },
      "message": "No module named Users\\brcan\\Desktop\\bunk\\tester.py"
    }
  ]
}

@ericsnowcurrently
Copy link
Member

I'm seeing a similar issue (on linux). With prospector enabled everything appears to work. However, the first message for each file is similar to the following:

[prospector - pylint] fatal:No module named home/<user>/<pkg>/spam.py

Two things to note:

  • the path has no leading slash
  • if I have linting failures in a file then it reports them correctly, even though it also reports the above fatal error

I'm not seeing any duplication in the reported path.

@DonJayamanne DonJayamanne added this to the March 2018 milestone Mar 7, 2018
DonJayamanne added a commit that referenced this issue Mar 22, 2018
…s to linters. (#1155)

* 🐛 format file names when passing as command line args
* 🐛 fix header check
* ✅ tests
* 📝 news entry
* Fixes #199
@lock lock bot locked as resolved and limited conversation to collaborators Jul 11, 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
3 participants