GeezerVison is showing github.com — Improve syntax error for invalid imports · Issue #98931 · python/cpython
Improve syntax error for invalid imports #98931
Description
Is quite common to type import x from y instead of from y import x. We can easily offer a better error message in this case.
Reacted by Trey Hunner
Reacted by Jelle Zijlstra, Lysandros Nikolaou, Trey Hunner, Charlie Zhao and Nelson Cárdenas Bolaño
Reacted by NamJin Kim and Ewan
Activity
added a commit that references this issue
on Nov 1, 2022gh-98931: Improve error message when the user types 'import x from y'…
martin-martin commented on Mar 7, 2023
Hi @pablogsal thanks for all your work on error messages. Is a similar situation, but where someone attempts to import more than one name from a module something we'd like to support?
Currently this situation doesn't benefit from your updates:
>>> import s, d from this
File "<stdin>", line 1
import s, d from this
^^^^
SyntaxError: invalid syntax
Just came across it, so I thought I'd leave a note. Thanks again!
pablogsal commented on Mar 7, 2023
Hi @pablogsal thanks for all your work on error messages. Is a similar situation, but where someone attempts to import more than one name from a module something we'd like to support?
Thanks a lot for the kind words and the suggestion! I will give some though to see how hard is to support this. :)
added 3 commits that reference this issue
on Jun 22, 2023pythongh-98931: Add custom error messages to invalid import/from with…
pythongh-98931: Add custom error messages to invalid import/from with…
gh-98931: Add custom error messages to invalid import/from with multi…
Metadata
Metadata
Development
No branches or pull requestsIssue actions