gh-98931: Improve error message when the user types 'import x from y' instead of 'from y import x'#98932
Merged
pablogsal merged 4 commits intopython:mainfrom Nov 1, 2022
Merged
Conversation
…rom y' instead of 'from y import x'
lysnikolaou
reviewed
Oct 31, 2022
Member
lysnikolaou
left a comment
There was a problem hiding this comment.
Good one! Just one suggestion for the error message.
Grammar/python.gram
Outdated
| 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?") } |
Member
There was a problem hiding this comment.
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?") } |
Member
Author
There was a problem hiding this comment.
Done! Thanks for the review :)
Member
There was a problem hiding this comment.
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'
Member
Author
|
Will fix the doctest tomorrow |
Co-authored-by: Charlie Zhao <zhaoyu_hit@qq.com>
Member
Author
|
🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes: #98931