-
-
Notifications
You must be signed in to change notification settings - Fork 34.4k
gh-69605: PyREPL: insert "import" after "from foo <tab>" #148445
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -1168,13 +1168,18 @@ def test_completions(self): | |||||||||||||
| ("import importlib.resources.\t\ta\t\n", "import importlib.resources.abc"), | ||||||||||||||
| ("import foo, impo\t\n", "import foo, importlib"), | ||||||||||||||
| ("import foo as bar, impo\t\n", "import foo as bar, importlib"), | ||||||||||||||
| ("from impo\t\n", "from importlib"), | ||||||||||||||
| ("from importlib.res\t\n", "from importlib.resources"), | ||||||||||||||
| ("from importlib.\t\tres\t\n", "from importlib.resources"), | ||||||||||||||
| ("from importlib.resources.ab\t\n", "from importlib.resources.abc"), | ||||||||||||||
| ("from impo\t\n", "from importlib "), | ||||||||||||||
|
||||||||||||||
| Input | Current | Proposed |
|---|---|---|
from math <tab> |
from math |
from math import |
from mat<tab> |
from math |
from math (no more extra space) |
from math<tab> |
from math |
from math import (insert space + import) |
That allow from mat<tab><tab> to still work, and should be quite straightforward, so at a glance I quite like it!
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.
I think having a different behaviour if the module has submodules or not would be both obscure and hard to implement.
Hard probably, but UX-wise I think it'd be nice if it added the space for modules that don't have submodules. It would save you one keystroke and immediately signal that there are no submodules to import from.
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.
Okay, I implemented the point 3 above, I tend to think it achieves the same smooth behavior (double tab to insert import) and is more simple to reason about.
But I'm eager to hear what you think, and happy to try and implement the "no submodules case" solution if we think it's better!
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| Insert ``import`` after ``from x.y.z <tab>`` in the :term:`REPL` | ||
| auto-completion. |
Uh oh!
There was an error while loading. Please reload this page.