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

"Expected expression" incorrectly reported for valid nested f-string #200

Closed
amachanic opened this issue Aug 4, 2020 · 2 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

@amachanic
Copy link

amachanic commented Aug 4, 2020

Environment data

  • Language Server version: 2020.7.4
  • OS and version: CentOS 7
  • Python version (& distribution if applicable, e.g. Anaconda): 3.6.3

Expected behaviour

No problems reported.

Actual behaviour

Pylance reports "Expected expression" and "Unexpected token at end of expression" problems in valid code.

image

Code Snippet / Additional information

x = f"""
    {
        f'''
        '''
    }
"""
@github-actions github-actions bot added the triage label Aug 4, 2020
@erictraut
Copy link
Contributor

Thanks for the bug report.

The issue isn't with the nested f-string, it's with the newline tokens within the outer f-string expression. The Python spec doesn't indicate that f-string expressions should be treated as though they are surrounded by parentheses, but clearly they are treated that way by the Python interpreter. I've fixed the issue, and it will work as expected in the next release.

In the meantime, you can work around the problem by either 1) removing the newline characters from within the curly brackets, or 2) surrounding the expression within the curly brackets with parentheses.

@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 Aug 4, 2020
@github-actions github-actions bot removed the triage label Aug 4, 2020
@jakebailey
Copy link
Member

This issue has been fixed in version 2020.8.0, which we've just released. You can find the changelog here: https://github.com/microsoft/pylance-release/blob/master/CHANGELOG.md#202080-5-august-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

3 participants