mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
gh-98931: Improve error message when the user types 'import x from y' instead of 'from y import x' (#98932)
This commit is contained in:
parent
0e15c31c7e
commit
395d4285bf
5 changed files with 503 additions and 392 deletions
|
@ -1584,6 +1584,22 @@ SyntaxError: trailing comma not allowed without surrounding parentheses
|
|||
Traceback (most recent call last):
|
||||
SyntaxError: trailing comma not allowed without surrounding parentheses
|
||||
|
||||
>>> import a from b
|
||||
Traceback (most recent call last):
|
||||
SyntaxError: Did you mean to use 'from ... import ...' instead?
|
||||
|
||||
>>> import a.y.z from b.y.z
|
||||
Traceback (most recent call last):
|
||||
SyntaxError: Did you mean to use 'from ... import ...' instead?
|
||||
|
||||
>>> import a from b as bar
|
||||
Traceback (most recent call last):
|
||||
SyntaxError: Did you mean to use 'from ... import ...' instead?
|
||||
|
||||
>>> import a.y.z from b.y.z as bar
|
||||
Traceback (most recent call last):
|
||||
SyntaxError: Did you mean to use 'from ... import ...' instead?
|
||||
|
||||
# Check that we dont raise the "trailing comma" error if there is more
|
||||
# input to the left of the valid part that we parsed.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue