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

Incorrectly reports an "= " inside a f-string as 'unexpected token' #182

Closed
fbidu opened this issue Jul 28, 2020 · 3 comments
Closed

Incorrectly reports an "= " inside a f-string as 'unexpected token' #182

fbidu opened this issue Jul 28, 2020 · 3 comments
Labels
bug Something isn't working fixed in next version (main) A fix has been implemented and will appear in an upcoming version

Comments

@fbidu
Copy link

fbidu commented Jul 28, 2020

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 = }")
@m1waterman88
Copy link

m1waterman88 commented Jul 28, 2020

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

@erictraut
Copy link
Contributor

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

@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 labels Jul 28, 2020
@jakebailey
Copy link
Member

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

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