3

Does anyone know how to specify correct Python version when use newest VSCode Python extension(ms-python.python) with multi-root workspace?

My global python environment is 2.7 and my VSCode project's directory structure is like below:

root ├ .vscode │ ├ childA(Python2.7) │ ├ .venv(virtualenv directory created by Pipenv) │ └ .vscode │ └ childB(Python3.7) │ ├ .venv(virtualenv directory created by Pipenv) └ .vscode

I set pythonPath both child directory's .vscode/settings.json file like below: "python.pythonPath": ".venv/bin/python"

Recently I updated VSCode Python extension, after that, under ChildB directory, Python extension always displays error message like below: [Python] invalid syntax, parameter annotations require 3.x [E16]

I use type annotation like below: def add(p1: int, p2: int) return p1 + p2

This error message is returned by Python Language Server that I found here: https://github.com/Microsoft/python-language-server/blob/7be329643299111cc1f0839d20aa9eb146b0d381/src/Analysis/Engine/Impl/Parsing/Parser.cs#L2088

When I doesn't use multi-root workspace, this error is not displayed.

I think newest Python extension can't recognize correct Python version that I set in .vscode/settings.json when I use multi-root workspace.

I want Python Language Server to recognize correct Python version in childB directory.

Any suggestions?

Jean-Francois T.
  • 11,549
  • 7
  • 68
  • 107
  • yes. it's `pls.childB_dir = ".vscode/settings.json"; pls.childB_dir.string_parse_multi_root()`. hope that helps. – Yang K Nov 16 '18 at 04:03
  • @YangK Thank you for your reply. But I am confused. Is this a VSCode setting? I can' find 'pls' or `string_parse_multi_root` settings. Or, if this is a Python code, Where do I have to put this code? – Kenta Katsumata Nov 16 '18 at 04:29

1 Answers1

0

Settings for a multi-root workspace are not specified in a vscode/settings.json file but in your .vscode-workspace file.

Brett Cannon
  • 14,438
  • 3
  • 45
  • 40
  • Thank you for your reply. But unfortunately it seems that VSCode intellicode plugin and Language Server doesn't recognize multi-root workspace at this time. https://github.com/Microsoft/vscode-extension-samples/tree/master/lsp-multi-server-sample – Kenta Katsumata Nov 21 '18 at 00:59
  • Correct, use Jedi in that case until support has been added: https://github.com/Microsoft/vscode-python/issues/3017 . – Brett Cannon Nov 21 '18 at 20:46
  • I see. Thanks a lot. – Kenta Katsumata Nov 22 '18 at 01:45