Skip to content
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

False positive on missing region for endregion comment #4496

Closed
ItsDrike opened this issue Jan 20, 2023 · 8 comments
Closed

False positive on missing region for endregion comment #4496

ItsDrike opened this issue Jan 20, 2023 · 8 comments
Assignees
Labels
addressed in next version Issue is fixed and will appear in next published version bug Something isn't working

Comments

@ItsDrike
Copy link

Describe the bug
After an update from 1.1.286 to 1.1.290, I'm experiencing a bug that falsly marks any # endregion comment as not having a matching # region , even though it is present.

To Reproduce
Create file with the following content:

# region: foo

x = 5

# endregion

Run pyright and notice an error on line 4, stating that endregion is missing a region.

Expected behavior
Pyright should be able to find the region tag above properly, and not report this error.

Screenshots or Code
image

@erictraut
Copy link
Collaborator

@debonte, any thoughts on this one?

@erictraut erictraut added the needs investigation Requires additional investigation to determine course of action label Jan 20, 2023
@ItsDrike
Copy link
Author

ItsDrike commented Jan 20, 2023

However doing

# region: foo

x = 5

# endregion: anything (not just 'foo')

works just fine and doesn't produce the error, and this also works:

# region

x = 5

# endregion

@debonte debonte self-assigned this Jan 20, 2023
@debonte
Copy link
Collaborator

debonte commented Jan 20, 2023

We changed how we decide if a comment is a region/endregion for this issue: microsoft/pylance-release#3765.

Seems like that may need some tweaking still.

@debonte debonte added addressed in next version Issue is fixed and will appear in next published version and removed needs investigation Requires additional investigation to determine course of action labels Jan 21, 2023
@debonte
Copy link
Collaborator

debonte commented Jan 21, 2023

Thanks for the bug report. This will be addressed in the next release.

@rchl
Copy link
Contributor

rchl commented Jan 22, 2023

I'll just add that this error has also triggered in a code that just had a comment that happened to start with a "region" word.

            for diagnostic, candidate in diagnostics:
                # Checking against points is inclusive unlike checking whether region intersects another
                # region which is exclusive (at region end) and we want an inclusive behavior in this case.

It's obviously easy to workaround by changing the position of the "region" word but just wanted to point it out, in case this is not supposed to trigger the error.

I'm not sure if there is any spec for how those markers should work but I guess the match pattern could be a bit stricter and require the comment to either end after # region or be directly followed by a semicolon.

@erictraut erictraut added the bug Something isn't working label Jan 23, 2023
@debonte
Copy link
Collaborator

debonte commented Jan 23, 2023

@rchl, unfortunately there's no standard for formatting #region/#endregion that I'm aware of. Perhaps there should be though. It would be nice if the behavior was consistent across editors.

Since the Pylance team owns this functionality, could you please file a new issue on this in the Pylance repo? https://github.com/microsoft/pylance-release/issues/new/choose

@rchl
Copy link
Contributor

rchl commented Jan 23, 2023

microsoft/pylance-release#3857

@erictraut
Copy link
Collaborator

This is included in pyright 1.1.291, which I just published. It will also be included in a future release of pylance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
addressed in next version Issue is fixed and will appear in next published version bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants