-
Notifications
You must be signed in to change notification settings - Fork 767
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
Showing error even if the file runs #219
Comments
Thanks for the bug report. There is indeed a bug in Pylance here, but there's also a bug in your code. Let me explain. You are using the backslash in your string in two locations. In Python strings, the backslash character is used to start an escape sequence. It is supposed to be followed by one or more other characters to complete the escape sequence. For example "\n" represents a new-line character and "\048" is an octal escape sequence. A full list of recognized escape sequences can be found in the Python documentation. Escape sequences that are not listed are considered bugs. In the current version of the Python interpreter, these cases are flagged with a deprecation warning, but in future versions they will be rejected as an error. Here's the text from the spec:
Pylance was incorrectly handling the unrecognized escape sequences found in your string literal. When it saw the backslash, it skipped over the next character. In the case of "{video}", it skipped the open bracket character. I've fixed this problem, and it will be corrected in the next version of Pylance. The way to fix the bug in your code is to use a double backslash "\" rather than a single backslash. Pylance contains code to warn you about unrecognized escape sequences, but this diagnostic is suppressed when typeCheckingMode is "off". If you set typeCheckingMode to "basic", you will see a warning for this condition. @savannahostrowski & @jakebailey , we might consider enabling the |
Thank You |
This issue has been fixed in version 2020.8.1, which we've just released. You can find the changelog here: https://github.com/microsoft/pylance-release/blob/master/CHANGELOG.md#202081-13-august-2020 |
Thank you very much.
I often use this style of writing to specify a file path in the Windows environment. |
Thanks for reporting. You are correct that pylance was not handling backslashes correctly within a raw f-string. This will be addressed in the next release. |
@erictraut |
Environment data
Expected behaviour
Error ("Single close brace not allowed within f-string literal; use double close brace") should not have occured
Actual behaviour
Error occuring at closing brace in {video} in the code provided
Logs
Code Snippet / Additional information
The text was updated successfully, but these errors were encountered: