-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Invalid syntax error in multi-line f-string with format spec #6077
Comments
I'm not able to repro the error with the code you've supplied above. Could you verify that your code sample is correct? For me, pyright emits another (correct) error indicating that a = 1
d = 1
f"""__{
a + d
}__""" |
Oh sorry, there are two cases here. The error thrown would be when using single quotes: f"__{
a:d
}__" The problem that exists when using triple-quotes is that the format spec includes the newline character which is invalid. I'm not sure if that's relevant in Pyright. |
Ah, I think you meant to use single quotes rather than triple quotes. f"__{
x:d
}__" Pyright's behavior matches that of the Python interpreter, so I consider it correct. I used the CPython test cases for PEP 701 to validate that pyright was working correctly here. If the CPython devs ultimately determine that this is a bug in the Python interpreter, then I'll make the corresponding change in pyright. But for now, I consider this to be correct behavior. |
Oh, I just noticed that @pablogsal has already acknowledged that this is a bug in CPython and has submitted a PR to address it. |
…ote form of a format string that uses a format specifier expression. This is also a bug in the Python 3.12 interpreter that is being fixed. This addresses #6077.
This issue will be addressed in the next release of pyright. |
This is addressed in pyright 1.1.330, which I just published. It will also be included in an upcoming release of pylance. |
Friendly reminder to review the discussion in python/cpython#110259 so you end implementing the same as CPython 😉 |
Describe the bug
Basically the same bug as reported in CPython (python/cpython#110259) exists in Pyright's lexer as well.
Code or Screenshots
Running
pyright
on the above code gives:VS Code extension or command-line
Running through the command-line using
1.1.329
The text was updated successfully, but these errors were encountered: