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

Associate errors with the start line instead of the end line (Better Syntax Errors as in Python 3.10) #2118

Closed
DonJayamanne opened this issue Nov 29, 2021 · 2 comments
Labels
fixed in next version (main) A fix has been implemented and will appear in an upcoming version

Comments

@DonJayamanne
Copy link
Collaborator

Current behaviour

Write the following code:

print(
1234

Error message should be assocated with the line containing print(, not error in line xyz.
Python 3.10 does a great job here (that's one of the most popular features announced in 3.10, at least from what I've seen when users publish articles about 3.10).

image

This is crucial for Notebooks as the errors are now associated with the first line of the next cell.
See below

image

Things get even worse if you have markdown cells (see below), as user has no clue what's wrong now.

image

Expected behaviour

Notebook users should not have to look for errors in the preceeding cell and figure out what's wrong (developer tools like LS should hel;p users figure it out). With notebooks users have to go to previous cell and look for errors there.

Syntax Errors should be handled as done in Python 3.10
image

Originally reported here microsoft/vscode-jupyter#6556

@erictraut
Copy link
Contributor

Thanks for the suggestion. I agree that parse errors involving missing parenthesis are clearer when they're associated with the starting parenthesis.

I've updated all of the parse errors related to parentheses, square brackets and braces (curly brackets) to follow this pattern and use an error message that more closely matches that of the Python 3.10 interpreter.

This change will be included in the next release of pylance.

@judej judej added the fixed in next version (main) A fix has been implemented and will appear in an upcoming version label Nov 30, 2021
@github-actions github-actions bot removed the triage label Nov 30, 2021
@bschnurr
Copy link
Member

bschnurr commented Dec 2, 2021

This issue has been fixed in version 2021.12.0, which we've just released. You can find the changelog here: CHANGELOG.md

@bschnurr bschnurr closed this as completed Dec 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fixed in next version (main) A fix has been implemented and will appear in an upcoming version
Projects
None yet
Development

No branches or pull requests

4 participants