I have this issue with VSCode and the Code Runner extension and here is the code snippet causing the issue:
class init_error(Exception):
def __init__(self, comp="Internals"):
self.component = comp
self.message = f"Error occurred while initiating {self.component}"
def __str__(self):
return self.message
I first thought it was mistaking the compiler between Python2 and Python3, but after specifying #!/usr/bin/env python3 and checking that print("foo") works, I was fairly certain that it was not a version issue. I have checked that the compiler in Code Runner is set to 3.7.4 64-bit so I tried running the code through the Python extension, and it worked, so I believe this is a Code Runner issue.
Sorry for being long, but lastly, the f-strings are NOT underlined in red and it does not come up as a problem, therefore for some reason, f-strings are considered to be valid syntax, but does not run in only the Code Runner extension.
How can I make Code Runner accept f-strings?
Thank you for the help.
P.S. I don't think this is relevant, but I could have sworn it worked a month ago.
Below are links to the steps I took to get f-strings to work in vs-Code



Try adding this is settings.json:
"code-runner.executorMap": {
"python": "$pythonPath -u $fullFileName"
},
"code-runner.clearPreviousOutput": true,
"code-runner.showExecutionMessage": false,
"code-runner.ignoreSelection": true,
"code-runner.saveFileBeforeRun": true,
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With