Skip to content

Improve syntax error for invalid imports #98931

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
pablogsal opened this issue Oct 31, 2022 · 2 comments · Fixed by #98932
Closed

Improve syntax error for invalid imports #98931

pablogsal opened this issue Oct 31, 2022 · 2 comments · Fixed by #98932

Comments

@pablogsal
Copy link
Member

pablogsal commented Oct 31, 2022

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.

pablogsal added a commit to pablogsal/cpython that referenced this issue Oct 31, 2022
pablogsal added a commit to pablogsal/cpython that referenced this issue Oct 31, 2022
…ort x from y' instead of 'from y import x'
pablogsal added a commit to pablogsal/cpython that referenced this issue Oct 31, 2022
…es 'import x from y' instead of 'from y import x'
pablogsal added a commit that referenced this issue Nov 1, 2022
@martin-martin
Copy link
Contributor

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
Copy link
Member Author

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. :)

pablogsal added a commit to pablogsal/cpython that referenced this issue Jun 22, 2023
pablogsal added a commit to pablogsal/cpython that referenced this issue Jun 22, 2023
… multiple targets

Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
pablogsal added a commit that referenced this issue Jun 22, 2023
…ple targets (#105985)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Jun 22, 2023
… multiple targets (pythonGH-105985)

(cherry picked from commit 13237a2)

Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
pablogsal added a commit that referenced this issue Jun 22, 2023
…h multiple targets (GH-105985) (#105991)

Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
bentasker pushed a commit to bentasker/cpython that referenced this issue Jun 23, 2023
… multiple targets (python#105985)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants