8000 gh-98931: Improve error message when the user types 'import x from y' instead of 'from y import x' by pablogsal · Pull Request #98932 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

Conversation

pablogsal
Copy link
Member
@pablogsal pablogsal commented Oct 31, 2022

Copy link
Member
@lysnikolaou lysnikolaou left a comment

Choose a reason for hiding this comment

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

Good one! Just one suggestion for the error message.

RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "cannot use double starred expression here") }
invalid_import:
| a='import' dotted_name 'from' dotted_name {
RAISE_SYNTAX_ERROR_STARTING_FROM(a, "Did you meant to use 'from ... import ...' instead?") }
Copy link
Member

Choose a reason for hiding this comment

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

Ditto in tests and docs.

Suggested change
RAISE_SYNTAX_ERROR_STARTING_FROM(a, "Did you meant to use 'from ... import ...' instead?") }
RAISE_SYNTAX_ERROR_STARTING_FROM(a, "Did you mean to use 'from ... import ...' instead?") }

Copy link
Member Author
@pablogsal pablogsal Oct 31, 2022

Choose a reason for hiding this comment

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

Done! Thanks for the review :)

Copy link
Member

Choose a reason for hiding this comment

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

Of course! I think you missed the one in whatsnew?

…ort x from y' instead of 'from y import x'
…es 'import x from y' instead of 'from y import x'
@pablogsal
Copy link
Member Author

Will fix the doctest tomorrow

Co-authored-by: Charlie Zhao <zhaoyu_hit@qq.com>
Copy link
Member
@lysnikolaou lysnikolaou left a comment

Choose a reason for hiding this comment

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

Go!

@pablogsal pablogsal merged commit 395d428 into python:main Nov 1, 2022
@pablogsal pablogsal deleted the gh-98931 branch November 1, 2022 13:01
@pablogsal
Copy link
Member Author

🚀

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 for invalid imports

4 participants

0