GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — 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

Conversation

@pablogsal

@pablogsal pablogsal commented Oct 31, 2022 •
edited by bedevere-bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Closes: #98931

  • Issue: Improve syntax error for invalid imports #98931

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@pablogsal
pythongh-98931: Improve error message when the user types 'import x f…
d6bb24d
…rom y' instead of 'from y import x'
@pablogsal
pablogsal requested a review from lysnikolaou as a code owner October 31, 2022 22:57
@bedevere-bot bedevere-bot mentioned this pull request Oct 31, 2022
Improve syntax error for invalid imports #98931
Closed
@bedevere-bot bedevere-bot added the awaiting core review label Oct 31, 2022
lysnikolaou
lysnikolaou reviewed Oct 31, 2022
View reviewed changes

@lysnikolaou lysnikolaou left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this 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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread 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?") }

@lysnikolaou lysnikolaou Oct 31, 2022

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

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?") }

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@pablogsal pablogsal Oct 31, 2022 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

lysnikolaou reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

@lysnikolaou lysnikolaou Oct 31, 2022

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

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?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

pablogsal reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
pablogsal added 2 commits October 31, 2022 23:05
@pablogsal
fixup! pythongh-98931: Improve error message when the user types 'imp…
207d6e1
…ort x from y' instead of 'from y import x'
@pablogsal
fixup! fixup! pythongh-98931: Improve error message when the user typ…
fb08d31
…es 'import x from y' instead of 'from y import x'
@pablogsal

pablogsal commented Oct 31, 2022

Copy link
Copy Markdown
Member Author

Will fix the doctest tomorrow

lysnikolaou reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

CharlieZhao95
CharlieZhao95 reviewed Nov 1, 2022
View reviewed changes
Comment thread Doc/whatsnew/3.12.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

@pablogsal @CharlieZhao95
Update Doc/whatsnew/3.12.rst
9f705af
Co-authored-by: Charlie Zhao <[email protected]>
lysnikolaou
lysnikolaou approved these changes Nov 1, 2022
View reviewed changes

@lysnikolaou lysnikolaou left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Go!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

pablogsal reacted with rocket emoji
All reactions
  • 🚀 1 reaction
@bedevere-bot bedevere-bot added awaiting merge and removed awaiting core review labels Nov 1, 2022
@pablogsal
pablogsal merged commit 395d428 into python:main Nov 1, 2022
@pablogsal
pablogsal deleted the gh-98931 branch November 1, 2022 13:01
@bedevere-bot bedevere-bot removed the awaiting merge label Nov 1, 2022
@pablogsal

pablogsal commented Nov 1, 2022

Copy link
Copy Markdown
Member Author

🚀

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@lysnikolaou lysnikolaou lysnikolaou approved these changes
+1 more reviewer
@CharlieZhao95 CharlieZhao95 CharlieZhao95 left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Improve syntax error for invalid imports

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@pablogsal @lysnikolaou @CharlieZhao95 @bedevere-bot
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.