Pylance-release: Incorrectly reports an "= " inside a f-string as 'unexpected token'

Created on 28 Jul 2020  路  3Comments  路  Source: microsoft/pylance-release

Hello! I just noticed that Pylance accepts f-strings with an equal sign at the end such as

print(f"{10 + 20 =}")

But it will complain with "invalid token" if a space is added after the = sign. I found this out while refactoring a test today:

Peek 28-07-2020 10-14

Environment data

  • Language Server version: 2020.7.3
  • OS and version: Fedora 32
  • Python version (& distribution if applicable, e.g. Anaconda): Python 3.8.3

Expected behaviour

Pylance should identify the space after an = sign as a valid token

Actual behaviour

It actually complains about the space

Logs


Python output logs as soon as I add the space and save:

> ~/.cache/pypoetry/virtualenvs/api-esther-AOXcjWyB-py3.8/bin/python ~/.vscode/extensions/ms-python.python-2020.7.96456/pythonFiles/pyvsc-run-isolated.py pylint --msg-template='{line},{column},{category},{symbol}:{msg}' --reports=n --output-format=text ~/dev/faculdade/api_esther/tests/api/test_help_asking.py
cwd: ~/dev/faculdade/api_esther
> ~/.cache/pypoetry/virtualenvs/api-esther-AOXcjWyB-py3.8/bin/python ~/.vscode/extensions/ms-python.python-2020.7.96456/pythonFiles/pyvsc-run-isolated.py pylint --msg-template='{line},{column},{category},{symbol}:{msg}' --reports=n --output-format=text ~/dev/faculdade/api_esther/tests/api/test_help_asking.py
cwd: ~/dev/faculdade/api_esther
> ~/.cache/pypoetry/virtualenvs/api-esther-AOXcjWyB-py3.8/bin/python ~/.vscode/extensions/ms-python.python-2020.7.96456/pythonFiles/testing_tools/run_adapter.py discover pytest -- --rootdir ~/dev/faculdade/api_esther -s --cache-clear tests
cwd: ~/dev/faculdade/api_esther
##########Linting Output - pylint##########

--------------------------------------------------------------------
Your code has been rated at 10.00/10 (previous run: 10.00/10, +0.00)

Code Snippet / Additional information

print(f"{10 + 20 = }")
bug fixed in next version

Most helpful comment

Thanks for the bug report. This will be fixed in the next version of Pylance.

All 3 comments

I came here to file an issue for this as well. PyLance is fine with f"{t1=}" and f"{t1 =}". It does not like a space after the equals sign: f"{t1= }" or f"{t1 = }".

Environment:
Pop!_OS 20.04

image

Thanks for the bug report. This will be fixed in the next version of Pylance.

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

Was this page helpful?
0 / 5 - 0 ratings