Skip to content

Conversation

@jyotiv06
Copy link

Fixes #4820

I validated the Following error message

image

I enhanced the Error reporting message to be more clear!

image
  • I reproduced the Error reporting message by Creating the exact Python code file.
  • Navigated to the src -> black -> parsing.py
  • In parsing.py, modified the Error reporting message to be more clear

I'm happy to revise this PR if needed. Please let me know if there are any changes or improvements you'd like.

@cobaltt7
Copy link
Collaborator

But not all syntax errors mean you're missing a colon...

@jyotiv06
Copy link
Author

@cobaltt7 You can check the latest commit!

f"Line {lineno}, Column {column}\n"
f"\n {faulty_line}\n"
f" {' ' * (column - 1)}^\n"
f"\nMissing a ':' or Invalid Syntax\n"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this line, it is likely to be misleading.

@jyotiv06 jyotiv06 force-pushed the improve-syntax-error-output branch 2 times, most recently from 49f8219 to a37b065 Compare November 19, 2025 03:33
@cobaltt7
Copy link
Collaborator

cobaltt7 commented Nov 21, 2025

This is not an improvement. It removes information that was previously included (line number & column). Jelle and I wanted the last line removed, because not all syntax errors are caused by missing semicolons, and what you had previously implied that most syntax errors were.

Take a look at the attributes of ParseError and see what would be helpful to log out. There may also be an opportunity to improve the TokenError message a few lines below, I'm not sure.

@cobaltt7
Copy link
Collaborator

cobaltt7 commented Jan 1, 2026

Closing because this isn't an improvement. Please feel free to open a new PR following my feedback above

@cobaltt7 cobaltt7 closed this Jan 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve syntax error reporting for a better user experience

3 participants