-
Notifications
You must be signed in to change notification settings - Fork 766
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
region
at the start of a normal comment triggers error about endregion
being missing
#3857
Comments
region
at the start of normal comment triggers error about endregion
being missingregion
at the start of a normal comment triggers error about endregion
being missing
@debonte dup? |
Not a dupe. This is really about multi-line comments that happen to have one line starting with "region". @rchl, thanks for filing this. |
I don't see a way to improve detection of
I think the best solution is to provide a way to disable the unmatched region diagnostics. This seems especially desirable in Pyright which doesn't support region folding. At least Pylance users have folding support as an incentive to get their @erictraut, any concerns with adding a new @rchl, would you be satisfied with this solution? Workarounds in the meantime to silence a particular instance of this diagnostic:
|
This doesn't strike me as something that justifies a new diagnostic rule. If we were to add a new diagnostic rule, it should definitely not have a different default because pyright and pylance. We don't have any precedent for that. The defaults are determined by the "none", "basic" or "strict" rule sets. My suggestion here is to make the parsing a bit more strict, along the lines of what you're suggesting above. Do you see any good reason why we'd want to interpret something as a |
I think this is true for |
Ah, that's unfortunate. Is a colon (or no following text) used in the majority of cases? Would it make sense to say "if you don't use a colon, we will not treat it as a region demarkation"? That would eliminate false positive errors at the expense of forcing some users to add colons if they want region demarkations to work. That sounds preferable to me than adding a switch that we need to maintain and that user need to toggle to eliminate false positive errors in what is otherwise perfectly legal comments that happen to contain the word "region".
Ah, I forgot about that. I think this is an unfortunate precedent. We receive frequent questions from users about how to get the same behaviors between pyright and pylance. The more we diverge, the harder this becomes. So I think we should maintain a high bar for any divergence. IMO, this doesn't meet that bar. |
Don't other languages (like TS or C#) support region demarkation comments? How do they deal with this case? Perhaps there's some precedent we should be following here. |
No. Searching on cs.github.com, I'm seeing about 1K with a colon, 1K with just whitespace, and 40+K with text and no colon.
C# doesn't use comments. It uses the TypeScript uses |
I'm reading those comments and I'm wondering whether we're missing an elephant in the room. My case was about comment that starts with |
@rchl, cs.github.com finds 6k files without a space ( To double check, i browsed through the files that had spaces and the ones I saw all appeared to be defining regions; they weren't comments that happened to contain the word "region" as in your case. |
This issue has been closed automatically because it needs more information and has not had recent activity. If the issue still persists, please reopen with the information requested. Thanks. |
Is there any way to disable this rule? Quite annoying. |
This also triggers on a commented-out line like At the very least there should be a setting to opt-out from region comment tracking. If you're doing geospatial work with entities called region, you're likely not using region/endregion anyways. |
I think at very least the start shouldn't be trimmed here: https://github.com/microsoft/pyright/blob/9a53b9962c763191690e48e92322d853df37ed0d/packages/pyright-internal/src/analyzer/regions.ts#L57. I think having |
This issue has been fixed in prerelease version 2024.2.101, which we've just released. You can find the changelog here: CHANGELOG.md |
Environment data
Code Snippet
Repro Steps
Expected behavior
No error about missing "endregion" pair
Actual behavior
Getting error about "endregion" missing
Logs
Not relevant
The text was updated successfully, but these errors were encountered: