Python-language-server: Support 3.8 fstring debug syntax in parser

Created on 20 May 2019  路  4Comments  路  Source: microsoft/python-language-server

Python 3.8 comes with a new fstring feature:

print(f"{name=}")
print(f"{name =}")
print(f"{name = }")
print(f"{foo.bar()=}")
# etc

Is equivalent to writing:

print(f"name={repr(name)}")
print(f"name ={repr(name)}")
print(f"name = {repr(name)}")
print(f"foo.bar()={repr(foo.bar())}")
# etc

We don't particularly need to know about the string that gets printed, but we'll have to handle the extra = at the end in 3.8+.

Note that these can be combined with ! stuff, so:

print(f"{foo=!s}")

https://bugs.python.org/issue36817

python-3.8

All 4 comments

greetings!
glad i found this thread because i've had a unresolved issue with python error analysis in vscode.
with this particular example, i'll get the red squiggles under the equal sign + the problems panel will list a problem for each use.
the info i can get from the problems panel (r-click copy) is cryptic. the important values() seem to be "_generated_diagnostic_collection_name_#3", "parser-16", "unexpected token '='".
i've been checking vscode/vscode-python repos occasionally but the issues get closed without solution. i may be mistaken but i think i rmbr even reading someone state that "parser-16" is unassociated with vscode-python.
here is what i know so far (having search this repo, as well):
parser-16 is a python-language-server "thing"[1].
i still get the "unexpected token" error with "python.linting.enabled" set false.
there are others who seem to be confused about what can/can't be done to minimize workflow disruptions[2]

i'm assuming this error cannot be ignored, but please correct me if i am wrong.

thanks! really do like this editor 馃憤

Can you please post a screenshot? Is this related to the extra = as mentioned in this issue?

https://docs.python.org/3.8/whatsnew/3.8.html#f-strings-support-for-self-documenting-expressions-and-debugging

ty jake, i apologize i had a family matter. i just checked my python code to get u a screenshot. but, as this thread shows, its all working now. still my main editor 馃挴

Was this page helpful?
0 / 5 - 0 ratings