syntax error with f-strings
See original GitHub issueEnvironment data
- VSCode Info: Version: 1.34.0-insider Commit: 0ab39f4148f242e7b0802330385fc99b4845aa31 Date: 2019-04-08T05:13:56.940Z Electron: 3.1.8 Chrome: 66.0.3359.181 Node.js: 10.2.0 V8: 6.6.346.32 OS: Linux x64 5.0.5-200.fc29.x86_64 (Fedora 29)
- VS Code version: 1.34.0-insider (commit 0ab39f414)
- Extension version (available under the Extensions sidebar): 2019.3.6558 (8 April 2019)
- OS and version: Linux x64 5.0.5-200.fc29.x86_64 (Fedora 29)
- Python version (& distribution if applicable, e.g. Anaconda): pypy3.5-6.0.0
- Type of virtual environment used (N/A | venv | virtualenv | conda | …): pyenv
- Relevant/affected Python packages and their versions: XXX
Expected behaviour
When using the new format string specifier, the code should be valid, and not display any problem.
Actual behaviour
When using the new format string specifier, the code is not valid, and displays the problems:
invalid syntax Python(parser-16) [24, 54]
Undefined variable: 'f' Python(undefined-variable) [24, 53]
In this screenshot, you can see the issues:
Steps to reproduce:
- create a new python file
- paste the following into the file:
print(f"I like the number {3}.")
- save and wait a few minutes (it takes a bit for the errors to be displayed.)
Logs
{
"resource": "[...]/elastic_mixin.py",
"owner": "_generated_diagnostic_collection_name_#1",
"code": "parser-16",
"severity": 8,
"message": "invalid syntax",
"source": "Python",
"startLineNumber": 24,
"startColumn": 54,
"endLineNumber": 24,
"endColumn": 71
}
{
"resource": "[...]/elastic_mixin.py",
"owner": "_generated_diagnostic_collection_name_#1",
"code": "undefined-variable",
"severity": 4,
"message": "Undefined variable: 'f'",
"source": "Python",
"startLineNumber": 24,
"startColumn": 53,
"endLineNumber": 24,
"endColumn": 54
}
Output from Console
under the Developer Tools
panel (toggle Developer Tools on under Help
; turn on source maps to make any tracebacks be useful by running Enable source map support for extension debugging
)
( no output )
Issue Analytics
- State:
- Created 4 years ago
- Comments:17 (8 by maintainers)
Top Results From Across the Web
python - f-strings giving SyntaxError? - Stack Overflow
I have python 3.6 installed and still get this error. Some program must still be running python 3.5 which I also have installed....
Read more >SyntaxError: f-string: expecting '}' in Python | bobbyhadz
The Python "SyntaxError: f-string: expecting '}'" occurs when we use single quotes inside of an f-string that was wrapped using single quotes.
Read more >Python 3 SyntaxError: invalid syntax f strings - Softhints
I was working on a old python project and I got error: filename = f"{file}_{user.replace('/', '_')}.txt" ^ SyntaxError: invalid syntax.
Read more >Question regarding Python 3.9 unable to read f strings
If I try to print them I'm given a syntax error. For the f string exercise one I just started running the full...
Read more >Invalid syntax with an f-string - Python Forum
I'll try to start using f-strings and getting used to this. Thanks!
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m using python 3.7.3 and this exact same issue happens to me too.
For reference, there are two issues here: