vscode-python: syntax error with f-strings

Environment 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: screenshot-parser-16-error

Steps to reproduce:

  1. create a new python file
  2. paste the following into the file:
print(f"I like the number {3}.")
  1. 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 )

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 17 (8 by maintainers)

Most upvoted comments

I’m using python 3.7.3 and this exact same issue happens to me too.