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

Comma in f-string is detected as "Unexpected token at end of expression " #551

Closed
sergeyf opened this issue Nov 2, 2020 · 6 comments
Closed
Labels
bug Something isn't working fixed in next version (main) A fix has been implemented and will appear in an upcoming version

Comments

@sergeyf
Copy link

sergeyf commented Nov 2, 2020

Environment data

  • Language Server version: v2020.10.3
  • OS and version: Windows 10, 19041.450
  • Python version (& distribution if applicable, e.g. Anaconda): 3.7, Anaconda

Expected behaviour

No issues with the f-string.

Actual behaviour

pylance detects an error in the f-string, next to the comma: "Unexpected token at end of expression"

Logs

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 'AA_testing - experiment'
User belongs to experiment group 'LocalZMQKernel - experiment'
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 - control'
User belongs to experiment group 'CustomEditorSupport - control'
User belongs to experiment group 'pythonaacf'
> conda --version
> pyenv root
> python3.7 c:\Users\serge\.vscode\extensions\ms-python.python-2020.10.332292344\pythonFiles\pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> python3.6 c:\Users\serge\.vscode\extensions\ms-python.python-2020.10.332292344\pythonFiles\pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> python3 c:\Users\serge\.vscode\extensions\ms-python.python-2020.10.332292344\pythonFiles\pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> python2 c:\Users\serge\.vscode\extensions\ms-python.python-2020.10.332292344\pythonFiles\pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> python c:\Users\serge\.vscode\extensions\ms-python.python-2020.10.332292344\pythonFiles\pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> py -3.7 c:\Users\serge\.vscode\extensions\ms-python.python-2020.10.332292344\pythonFiles\pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> py -3.6 c:\Users\serge\.vscode\extensions\ms-python.python-2020.10.332292344\pythonFiles\pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> py -3 c:\Users\serge\.vscode\extensions\ms-python.python-2020.10.332292344\pythonFiles\pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> py -2 c:\Users\serge\.vscode\extensions\ms-python.python-2020.10.332292344\pythonFiles\pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> C:\miniconda\python.exe c:\Users\serge\.vscode\extensions\ms-python.python-2020.10.332292344\pythonFiles\pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
Python interpreter path: C:\miniconda\python.exe
Starting Pylance language server.
Error 2020-11-02 14:59:19: Detection of Python Interpreter for Command python and args  failed as file  does not exist
Error 2020-11-02 14:59:19: Detection of Python Interpreter for Command python3 and args  failed as file  does not exist
> C:\miniconda\Scripts\conda.exe info --json
> C:\miniconda\Scripts\conda.exe env list
> C:\miniconda\Scripts\conda.exe info --json
> C:\miniconda\Scripts\conda.exe info --json
Error 2020-11-02 14:59:19: Failed to get interpreter information for 'C:\Users\serge\AppData\Local\Microsoft\WindowsApps\python3.exe' [Error: Command failed: "C:\\Users\serge\AppData\Local\Microsoft\WindowsApps\python3.exe" "c:\Users\serge\.vscode\extensions\ms-python.python-2020.10.332292344\pythonFiles\pyvsc-run-isolated.py" "c:\Users\serge\.vscode\extensions\ms-python.python-2020.10.332292344\pythonFiles\interpreterInfo.py"
Python was not found but can be installed from the Microsoft Store: https://go.microsoft.com/fwlink?linkID=2082640
	at ChildProcess.exithandler (child_process.js:304:12)
	at ChildProcess.emit (events.js:223:5)
	at maybeClose (internal/child_process.js:1021:16)
	at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5)] {
  killed: false,
  code: 9009,
  signal: null,
  cmd: '"C:\\\\Users\\serge\\AppData\\Local\\Microsoft\\WindowsApps\\python3.exe" "c:\\Users\\serge\\.vscode\\extensions\\ms-python.python-2020.10.332292344\\pythonFiles\\pyvsc-run-isolated.py" "c:\\Users\\serge\\.vscode\\extensions\\ms-python.python-2020.10.332292344\\pythonFiles\\interpreterInfo.py"'
}
Error 2020-11-02 14:59:19: Failed to get interpreter information for 'C:\Users\serge\AppData\Local\Microsoft\WindowsApps\python.exe' [Error: Command failed: "C:\\Users\serge\AppData\Local\Microsoft\WindowsApps\python.exe" "c:\Users\serge\.vscode\extensions\ms-python.python-2020.10.332292344\pythonFiles\pyvsc-run-isolated.py" "c:\Users\serge\.vscode\extensions\ms-python.python-2020.10.332292344\pythonFiles\interpreterInfo.py"
Python was not found but can be installed from the Microsoft Store: https://go.microsoft.com/fwlink?linkID=2082640
	at ChildProcess.exithandler (child_process.js:304:12)
	at ChildProcess.emit (events.js:223:5)
	at maybeClose (internal/child_process.js:1021:16)
	at Socket.<anonymous> (internal/child_process.js:430:11)
	at Socket.emit (events.js:223:5)
	at Pipe.<anonymous> (net.js:664:12)] {
  killed: false,
  code: 9009,
  signal: null,
  cmd: '"C:\\\\Users\\serge\\AppData\\Local\\Microsoft\\WindowsApps\\python.exe" "c:\\Users\\serge\\.vscode\\extensions\\ms-python.python-2020.10.332292344\\pythonFiles\\pyvsc-run-isolated.py" "c:\\Users\\serge\\.vscode\\extensions\\ms-python.python-2020.10.332292344\\pythonFiles\\interpreterInfo.py"'
}
> C:\miniconda\python.exe c:\Users\serge\.vscode\extensions\ms-python.python-2020.10.332292344\pythonFiles\pyvsc-run-isolated.py -c "import notebook"
> C:\miniconda\python.exe c:\Users\serge\.vscode\extensions\ms-python.python-2020.10.332292344\pythonFiles\pyvsc-run-isolated.py -c "import jupyter"
> C:\miniconda\Scripts\conda.exe info --json
> C:\miniconda\python.exe c:\Users\serge\.vscode\extensions\ms-python.python-2020.10.332292344\pythonFiles\pyvsc-run-isolated.py jupyter kernelspec --version
> C:\miniconda\Scripts\conda.exe env list
> C:\miniconda\python.exe c:\Users\serge\.vscode\extensions\ms-python.python-2020.10.332292344\pythonFiles\pyvsc-run-isolated.py black --line-length 120 --diff --quiet "c:\Users\serge\Google Drive\code\Gates Foundation\temp.py.32bd06e44fc5f43ec929d89a7b0d996d.tmp"
cwd: c:\Users\serge\.vscode\extensions\ms-python.python-2020.10.332292344\out\client
> C:\miniconda\python.exe c:\Users\serge\.vscode\extensions\ms-python.python-2020.10.332292344\pythonFiles\pyvsc-run-isolated.py black --line-length 120 --diff --quiet "c:\Users\serge\Google Drive\code\Gates Foundation\temp.py.32bd06e44fc5f43ec929d89a7b0d996d.tmp"
cwd: c:\Users\serge\.vscode\extensions\ms-python.python-2020.10.332292344\out\client
> C:\miniconda\python.exe c:\Users\serge\.vscode\extensions\ms-python.python-2020.10.332292344\pythonFiles\pyvsc-run-isolated.py c:\Users\serge\.vscode\extensions\ms-python.python-2020.10.332292344\pythonFiles\normalizeForInterpreter.py "x = "yes"
y = "no"
f"The woods are hollow? {x, y}"
"

Code Snippet / Additional information

x = 'yes'
y = 'no'
f'The woods are hollow? {x, y}'  # pylance red squiggle is on the comma.
@github-actions github-actions bot added the triage label Nov 2, 2020
@erictraut
Copy link
Contributor

Thanks for the bug report. This will be fixed in the next release.

@erictraut erictraut added bug Something isn't working fixed in next version (main) A fix has been implemented and will appear in an upcoming version and removed triage labels Nov 3, 2020
@sergeyf
Copy link
Author

sergeyf commented Nov 3, 2020

Thanks! I'm loving pylance so far :)

@jakebailey
Copy link
Member

This issue has been fixed in version 2020.11.0, which we've just released. You can find the changelog here: https://github.com/microsoft/pylance-release/blob/master/CHANGELOG.md#2020110-4-november-2020

@sergeyf
Copy link
Author

sergeyf commented Nov 4, 2020

Awesome, thank you very much.

@Travis-Prall
Copy link

I'd also like to point out this is till finding errors with:

self.error(f'Get Temp Dict: {Error=}', level='ERROR')

Where the problem seems to be any variable in an F-string that has an equal sign. In this example it is {Error=} where it has a problem with the = .

@erictraut
Copy link
Contributor

@Travis-Prall, if you think you are seeing a bug with f-string formatting, could you please file a new bug report? This issue has been closed for a long time, and the issue you seem to be seeing is unrelated to the original problem in this bug report.

I'm not able to repro the problem you are seeing. Perhaps there's additional context that's needed. It would be helpful if you could provide a self-contained example. For example, I don't know where the symbol Error comes from or how it is declared.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed in next version (main) A fix has been implemented and will appear in an upcoming version
Projects
None yet
Development

No branches or pull requests

4 participants