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
Emit warning for unmatched #region
/#endregion
#3308
Comments
This issue has been fixed in prerelease version 2022.11.41, which we've just released. You can find the changelog here: CHANGELOG.md |
Fixing this by emitting a warning does not look like a good idea to me. The At least let people turn off this type of warning in the settings. |
Perhaps we should just remove this diagnostic altogether. Is it providing enough value to justify its existence? If someone forgets to provide an |
That's only true for the last #region 1
...
#User intended to put an endregion here but forgot, deleted it, moved it with cut/copy paste, etc.
...
#region 2
...
#endregion This will result in two unexpected behaviors:
Pylance isn't strictly a type checker though, right? It's also a language server. This diagnostic was intended to complement Pylance's support of I agree that this diagnostic provides very little value for Pyright users, which is why I was suggesting that the default behavior in Pyright and Pylance should be different. |
@bkkm78, we're actually discussing that specific issue over at #3857
It's also supported by PyCharm for what that's worth. I'm not sure how many other Python editors / language servers support it. I agree that I asked Brett Cannon about writing a PEP to standardize the behavior of
PyCharm also has this issue where comments containing the word "region" are treated as the start of a folding region. If we had a proposal for addressing that, beyond disabling the feature, I would be happy to start a discussion with PyCharm and others on discuss.python.org so the behavior is consistent across editors. |
We support folding of
#region
/#endregion
pairs, but when there's an unmatched#region
or unmatched#endregion
our behavior will be surprising to the user.For example, in this scenario, the user apparently omitted an
#endregion
for the inner#region
. The result is that the inner#region
has a folding control>
, but the folding range unexpectedly ends at the "outer"#endregion
:This can also be caused by a typo. For example, in the following case the region is not foldable because
#endregion
is misspelled:TypeScript doesn't seem to warn for this issue, but C# flags these types of situations with "CS1038: #endregion directive expected" for an unmatched
#region
and "CS1028: Unexpected preprocessor directive" for an unmatched#endregion
.The text was updated successfully, but these errors were encountered: