-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Python longstring tag vs block comment tag in Vscode #23703
Comments
Thanks for creating this issue! It looks like you may be using an old version of VS Code, the latest stable release is 1.90.0. Please try upgrading to the latest version and checking whether this issue remains. Happy Coding! |
It's not yet available due to the company policy. |
Hi @Apamobil, I am struggling to reproduce any wrong behaviour in VS Code with longstrings defined by |
Hi! In a nutshell: Vscode misleadingly returns longstring tag ''' as a block comment tag for Python. According to the Python language specification longstring tag is not intended for comments, but for long strings as the name states. This is often used as an alternative method for commenting out multiple lines (using triple-quoted string literals (''' ''' or """ """). However, they are not officially block comments for Python. The problem is that automated formatters and linters don't like the longstring tags and are sometimes formatting the comments marked with longstring tags. See also this article, it gives some background info about commenting in Python: https://www.datacamp.com/tutorial/python-block-comment |
@Apamobil would you mind explaining what you mean by "VS Code returns a longstring tag as a block comment tag"? The reason why I'm not following what's happening is that the rendering of comments blocks with But perhaps the problem isn't with VS Code itself but with a linter or formatter extension you're using? |
I'm also a bit on a thin ice here myself since the colleague who reported this behavior is on a leave and I wrote this ticket on behalf of him. I think the problem is that Vscode LanguageConfiguration includes either line comment tag and or block comment tags. The extension in question uses by default block comments. The block comments for python are implemented as ''' in Vscode and it is against the python language reference. And this causes problems with linters/formatters. Does this make it any more clear? :) |
Hi all, Because Python language supports only line comment (that is starting with character '#') then it is not right that the Vscode returns from the LanguageConfiguration also a block comment tag, because there does not exist such thing in Python language. Reference: https://docs.python.org/3/reference/lexical_analysis.html#comments Now that we know that LanguageConfiguration shall not contain a value for Python block comment it should be fixed to not contain the block comment tag value. We have real issues related to this and hope that this would be fixed to make behaviour compliant with the official Python language reference. Thanks for anyone reading this :) |
Does this issue occur when all extensions are disabled?: Yes
DESCRIPTION
Vscode Language Configuration includes either line comment tag and or block comment tags. The extension we have been developing uses by default (based on implementation decision) block comments if they exist for the programming/script language of the current file.
The problem is with Python block comments and Vscode. Vscode misleadingly returns longstring tag ''' as a block comment tag that must be used in the beginning and end of a multi-line comment. However, according to the Python language specification the longstring tag is NOT for comments, but for long strings (as its name states).
From Python language reference:
2.1.3. Comments
2.4.1. String and Bytes literals
It seems this is a bug in Vscode implementation. It should be corrected in a way that so that language configuration does not contain longer longstring tag (''') as a block comment tag for Python comment.
The text was updated successfully, but these errors were encountered: