Run selection indentation error
See original GitHub issueEnvironment data
- VS Code version:
- OS and version:
Version: 1.49.1 Commit: 58bb7b2331731bf72587010e943852e13e6fd3cf Date: 2020-09-16T23:21:17.533Z (6 days ago) Electron: 9.2.1 Chrome: 83.0.4103.122 Node.js: 12.14.1 V8: 8.3.110.13-electron.0 OS: Darwin x64 19.6.0
- Extension version (available under the Extensions sidebar):
2020.8.1 (20 August 2020)
- Python version (& distribution if applicable, e.g. Anaconda):
Python 3.7.8, Python 3.8.4
- Type of virtual environment used (N/A | venv | virtualenv | conda | …):
venv, and without a virtual environment
- Relevant/affected Python packages and their versions:
N/A
- Relevant/affected Python-related VS Code extensions and their versions:
N/A
- Value of the
python.languageServer
setting:
Pylance
[NOTE: If you suspect that your issue is related to the Microsoft Python Language Server (python.languageServer: 'Microsoft'
), please download our new language server Pylance from the VS Code marketplace to see if that fixes your issue]
Expected behaviour
When I highlight Python code and run selection I expect it to run if it is syntactically correct.
Actual behaviour
I’m receiving indentation errors in specific scenarios for code that is syntactically correct.
Steps to reproduce:
[NOTE: Self-contained, minimal reproducing code samples are extremely helpful and will expedite addressing your issue]
Run selection on the following code and the following error(s) will occur
if False:
print("if")
elif True:
print("elif")
else:
print("else")
if False:
... print("if")
...
>>> elif True:
File "<stdin>", line 1
elif True:
^
SyntaxError: invalid syntax
>>> print("elif")
File "<stdin>", line 1
print("elif")
^
IndentationError: unexpected indent
>>> else:
File "<stdin>", line 1
else:
^
SyntaxError: invalid syntax
>>> print("else")
File "<stdin>", line 1
print("else")
^
IndentationError: unexpected indent
>>>
If I copy/paste the same code into the Python interactive window it will run without error.
Logs
Output for Python
in the Output
panel (View
→Output
, change the drop-down the upper-right of the Output
panel to Python
)
User belongs to experiment group 'AlwaysDisplayTestExplorer - control'
User belongs to experiment group 'ShowPlayIcon - start'
User belongs to experiment group 'DebugAdapterFactory - experiment'
User belongs to experiment group 'PtvsdWheels37 - experiment'
User belongs to experiment group 'UseTerminalToGetActivatedEnvVars - control'
User belongs to experiment group 'LocalZMQKernel - control'
User belongs to experiment group 'CollectLSRequestTiming - control'
User belongs to experiment group 'CollectNodeLSRequestTiming - experiment'
User belongs to experiment group 'EnableIPyWidgets - experiment'
User belongs to experiment group 'RunByLine - experiment'
User belongs to experiment group 'CustomEditorSupport - control'
User belongs to experiment group 'pythonaacf'
User belongs to experiment group 'pythonTipPromptWording'
> conda --version
> conda info --json
> pyenv root
> python3.7 ~/.vscode/extensions/ms-python.python-2020.9.106471-dev/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> python3.6 ~/.vscode/extensions/ms-python.python-2020.9.106471-dev/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> python2 ~/.vscode/extensions/ms-python.python-2020.9.106471-dev/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> python ~/.vscode/extensions/ms-python.python-2020.9.106471-dev/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> /usr/local/bin/python3 ~/.vscode/extensions/ms-python.python-2020.9.106471-dev/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> python3 ~/.vscode/extensions/ms-python.python-2020.9.106471-dev/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
Error 2020-09-22 22:05:40: Failed to download and store experiments, Class name = b, completed in 528ms, has a falsy return value, , Return Value: undefined [Error: Failed with status 404, Not Found, Uri https://raw.githubusercontent.com/microsoft/vscode-python/master/experiments.json
at H._callback (/Users/dplumley/.vscode/extensions/ms-python.python-2020.9.106471-dev/out/client/extension.js:54:716477)
at H.a._callback.a.callback.a.callback (/Users/dplumley/.vscode/extensions/ms-python.python-2020.9.106471-dev/out/client/node_modules/request.js:189:5442)
at H.emit (events.js:223:5)
at H.<anonymous> (/Users/dplumley/.vscode/extensions/ms-python.python-2020.9.106471-dev/out/client/node_modules/request.js:189:18302)
at H.emit (events.js:223:5)
at IncomingMessage.<anonymous> (/Users/dplumley/.vscode/extensions/ms-python.python-2020.9.106471-dev/out/client/node_modules/request.js:189:17134)
at Object.onceWrapper (events.js:312:28)
at IncomingMessage.emit (events.js:228:7)
at endReadableNT (_stream_readable.js:1185:12)
at processTicksAndRejections (internal/process/task_queues.js:81:21)]
Error 2020-09-22 22:05:40: Failed to initialize experiments, Class name = b, completed in 535ms, has a falsy return value, , Return Value: undefined [Error: Failed with status 404, Not Found, Uri https://raw.githubusercontent.com/microsoft/vscode-python/master/experiments.json
at H._callback (/Users/dplumley/.vscode/extensions/ms-python.python-2020.9.106471-dev/out/client/extension.js:54:716477)
at H.a._callback.a.callback.a.callback (/Users/dplumley/.vscode/extensions/ms-python.python-2020.9.106471-dev/out/client/node_modules/request.js:189:5442)
at H.emit (events.js:223:5)
at H.<anonymous> (/Users/dplumley/.vscode/extensions/ms-python.python-2020.9.106471-dev/out/client/node_modules/request.js:189:18302)
at H.emit (events.js:223:5)
at IncomingMessage.<anonymous> (/Users/dplumley/.vscode/extensions/ms-python.python-2020.9.106471-dev/out/client/node_modules/request.js:189:17134)
at Object.onceWrapper (events.js:312:28)
at IncomingMessage.emit (events.js:228:7)
at endReadableNT (_stream_readable.js:1185:12)
at processTicksAndRejections (internal/process/task_queues.js:81:21)] {
vslsStack: [
CallSite {}, CallSite {},
CallSite {}, CallSite {},
CallSite {}, CallSite {},
CallSite {}, CallSite {},
CallSite {}, CallSite {}
]
}
Python interpreter path: /usr/local/bin/python3
Starting Pylance language server.
> /usr/local/bin/python3 ~/.vscode/extensions/ms-python.python-2020.9.106471-dev/pythonFiles/pyvsc-run-isolated.py -c "import jupyter"
> /usr/local/bin/python3 ~/.vscode/extensions/ms-python.python-2020.9.106471-dev/pythonFiles/pyvsc-run-isolated.py -c "import jupyter"
> /usr/local/bin/python3 ~/.vscode/extensions/ms-python.python-2020.9.106471-dev/pythonFiles/pyvsc-run-isolated.py -c "import notebook"
> /usr/local/bin/python3 ~/.vscode/extensions/ms-python.python-2020.9.106471-dev/pythonFiles/pyvsc-run-isolated.py -c "import notebook"
> conda --version
> /usr/local/bin/python3 ~/.vscode/extensions/ms-python.python-2020.9.106471-dev/pythonFiles/pyvsc-run-isolated.py ~/.vscode/extensions/ms-python.python-2020.9.106471-dev/pythonFiles/normalizeForInterpreter.py "if False:
print("if")
elif True:
print("elif")
else:
print("else")"
> /usr/local/bin/python3 ~/.vscode/extensions/ms-python.python-2020.9.106471-dev/pythonFiles/pyvsc-run-isolated.py ~/.vscode/extensions/ms-python.python-2020.9.106471-dev/pythonFiles/normalizeForInterpreter.py "if False:
print("if")
elif True:
print("elif")
else:
print("else")"
> /usr/local/bin/python3 ~/.vscode/extensions/ms-python.python-2020.9.106471-dev/pythonFiles/pyvsc-run-isolated.py ~/.vscode/extensions/ms-python.python-2020.9.106471-dev/pythonFiles/normalizeForInterpreter.py "if False:
print("if")
elif True:
print("elif")
else:
print("else")"
> /usr/local/bin/python3 ~/.vscode/extensions/ms-python.python-2020.9.106471-dev/pythonFiles/pyvsc-run-isolated.py ~/.vscode/extensions/ms-python.python-2020.9.106471-dev/pythonFiles/normalizeForInterpreter.py "if False:
print("if")
elif True:
print("elif")
else:
print("else")"
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (2 by maintainers)
Top GitHub Comments
This should be fixed on our newest release, version 2021.1.502429796, but if you’re still seeing this let us now 😊
Nice. It helps a lot.