# Looking for feedback on adding import autocomplete to PyREPL

**URL:** <https://discuss.python.org/t/looking-for-feedback-on-adding-import-autocomplete-to-pyrepl/82281>\
**Category:** Core Development\
**Created:** [February 26, 2025, 7:48pm UTC](https://discuss.python.org/t/looking-for-feedback-on-adding-import-autocomplete-to-pyrepl/82281 "2025-02-26T19:48:55Z")\
**Posts on this page:** 20\
**Page:** 3

<div class="post-metadata">

**Author:** ![tomasr8](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/tomasr8/32/11872_2.png) [@tomasr8](https://discuss.python.org/u/tomasr8)\
**Post date:** [May 28, 2025, 11:50am UTC](https://discuss.python.org/t/looking-for-feedback-on-adding-import-autocomplete-to-pyrepl/82281/41 "2025-05-28T11:50:29Z")

</div>

Keep in mind that this currently lives in a private module inside pyrepl (which is itself private) so the implementation is subject to breaking changes without notice.

However, if you really want to use it, this should do what you want:

```pycon
>>> from _pyrepl._module_completer import ModuleCompleter
>>> c = ModuleCompleter()
>>> c.get_completions('import pa')
['pathlib']

```

---

<div class="post-metadata">

**Author:** ![AA-Turner](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/aa-turner/32/4979_2.png) [@AA-Turner](https://discuss.python.org/u/AA-Turner)\
**Post date:** [May 28, 2025, 12:49pm UTC](https://discuss.python.org/t/looking-for-feedback-on-adding-import-autocomplete-to-pyrepl/82281/42 "2025-05-28T12:49:01Z")

</div>

@tomasr8

```pycon
>>> from sys import e <TAB> <TAB>
elif else enumerate( eval( except exec( exit(

```

Can we remove keywords and builtins from the autocomplete set?

A

---

<div class="post-metadata">

**Author:** ![patrick-kidger](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/patrick-kidger/32/15089_2.png) [@patrick-kidger](https://discuss.python.org/u/patrick-kidger)\
**Post date:** [May 28, 2025, 7:49pm UTC](https://discuss.python.org/t/looking-for-feedback-on-adding-import-autocomplete-to-pyrepl/82281/43 "2025-05-28T19:49:11Z")

</div>

Awesome, thank you! If this ever becomes public somewhere then I’d definitely be a user.

---

<div class="post-metadata">

**Author:** ![tomasr8](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/tomasr8/32/11872_2.png) [@tomasr8](https://discuss.python.org/u/tomasr8)\
**Post date:** [May 28, 2025, 8:45pm UTC](https://discuss.python.org/t/looking-for-feedback-on-adding-import-autocomplete-to-pyrepl/82281/44 "2025-05-28T20:45:20Z")

</div>

This should be the case already. It was added/fixed in [gh-69605: Disable PyREPL module autocomplete fallback on regular completion by loic-simon · Pull Request #134181 · python/cpython · GitHub](https://github.com/python/cpython/pull/134181) 🙂

---

<div class="post-metadata">

**Author:** ![ElevenPhonons](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/elevenphonons/32/29009_2.png) [@ElevenPhonons](https://discuss.python.org/u/ElevenPhonons)\
**Post date:** [October 2, 2025, 7:52pm UTC](https://discuss.python.org/t/looking-for-feedback-on-adding-import-autocomplete-to-pyrepl/82281/45 "2025-10-02T19:52:34Z")

</div>

```python
>>> sys.version_info
sys.version_info(major=3, minor=15, micro=0, releaselevel='alpha', serial=0)
>>> from _pyrepl._module_completer import ModuleCompleter
>>> c = ModuleCompleter()
>>> f = c.get_completions
>>> f('import pa')
['pathlib']
>>> f('from pathlib import ')
['types']
>>> f('from pathlib import P')
[]
>>> f('from collections import ')
['abc']
>>> f('from collections import deq')
[]
>>> f('from typing import ')
[]
>>> f('from typing import T')
[]

```

The current behavior is a bit surprising. Is the autocomplete working as expected?

Where are the requirements for the autocomplete defined?

---

<div class="post-metadata">

**Author:** ![AA-Turner](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/aa-turner/32/4979_2.png) [@AA-Turner](https://discuss.python.org/u/AA-Turner)\
**Post date:** [October 2, 2025, 9:11pm UTC](https://discuss.python.org/t/looking-for-feedback-on-adding-import-autocomplete-to-pyrepl/82281/46 "2025-10-02T21:11:13Z")

</div>

Yes, autocompletion of module attributes (members) [is not currently supported](https://docs.python.org/3.14/whatsnew/3.14.html#other-language-changes).

A

---

<div class="post-metadata">

**Author:** ![loic-simon](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/loic-simon/32/37461_2.png) [@loic-simon](https://discuss.python.org/u/loic-simon)\
**Post date:** [October 26, 2025, 5:08pm UTC](https://discuss.python.org/t/looking-for-feedback-on-adding-import-autocomplete-to-pyrepl/82281/47 "2025-10-26T17:08:48Z")

</div>

To make progress on this topic, I prepared a POC with these two ideas:

> [@tomasr8](#):
>
> Allow imports but ask for a confirmation (e.g. first `<tab>` shows a message, second `<tab>` imports)

> [@encukou](#):
>
> Perhaps lean into this being a heavier and less secure operation, and bind it to another key? Something like `[press F8 to import 'foo']`?

Both are a bit hacky, but not too complicated changes:

- [PR for TAB mode](https://github.com/loic-simon/cpython/pull/2)
- [PR for F8 mode](https://github.com/loic-simon/cpython/pull/1)\[1\]

And to make it easy for everyone to test, I prepared a ✨ [**WebAssembly interactive demo**](https://pyrepl-attributes-import-completion.pages.dev/) ✨ _(totally hijacked from the [PEP 810 demo](https://lazy-import-demo.pages.dev/), thanks a lot Pablo for the hard work\[2\])_!

* * *

I personaly find TAB mode more convenient to use (especially with laptops where you must hit a combination of keys to enter F8), but I totally understand the security concern behind it.

* * *

1. the tests are those of TAB mode, I’ll rewrite them when needed 

2. It even use their Python build, so lazy imports work here too, but 🤫

---

<div class="post-metadata">

**Author:** ![sarahrod](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/sarahrod/32/31523_2.png) [@sarahrod](https://discuss.python.org/u/sarahrod)\
**Post date:** [October 26, 2025, 6:20pm UTC](https://discuss.python.org/t/looking-for-feedback-on-adding-import-autocomplete-to-pyrepl/82281/48 "2025-10-26T18:20:52Z")

</div>

This is a really nice approach tbh. I’ve been playing with the demo and the TAB mode makes sense to me at least.

I agree with you that TAB mode is more practical than F8. Having to remember a special function key for this seems annoying especially on laptops where your hitting Fn+F8 or whatever. The double-tab pattern is way more intuitive and its already a habit for most people anyway.

From what i can tell the original concern was mostly about modules getting imported silently which could be slow or have side effects. With the confirmation step that concern goes away. If someone doesnt want to import they just dont hit tab again.

---

<div class="post-metadata">

**Author:** ![timhoffm](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/timhoffm/32/19468_2.png) [@timhoffm](https://discuss.python.org/u/timhoffm)\
**Post date:** [October 26, 2025, 10:22pm UTC](https://discuss.python.org/t/looking-for-feedback-on-adding-import-autocomplete-to-pyrepl/82281/49 "2025-10-26T22:22:03Z")

</div>

If safety / unintended usage are a concern, one could also go to a true double-tab operation, i.e. similar to a mouse double-click one would have to hit tab twice in short sequence. Hitting tab multiple times with delay would only show the warning but not trigger the import.

Possible positive side effect: we could leave out the message on immediate double-tab. That way experienced users are not bothered with the warning/notification anbout import.

---

<div class="post-metadata">

**Author:** ![encukou](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/encukou/32/2461_2.png) [@encukou](https://discuss.python.org/u/encukou)\
**Post date:** [October 27, 2025, 9:21am UTC](https://discuss.python.org/t/looking-for-feedback-on-adding-import-autocomplete-to-pyrepl/82281/50 "2025-10-27T09:21:07Z")

</div>

Perhaps I’m _too_ experienced, but sometimes hit tab _three_ times quickly without much thought. (1 to complete a common suffix and 2 show the “menu” of non-unique completions. `_pyrepl` only needs two tabs for this but my shell needs all three.)  
I’m not convinced we need “security” here, but if we do, I wouldn’t go with double-tab.

* * *

Yeah, F8 was a silly example of “another key”.  
Shift+Tab maybe?

---

<div class="post-metadata">

**Author:** ![pitrou](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/pitrou/32/28_2.png) [@pitrou](https://discuss.python.org/u/pitrou)\
**Post date:** [October 27, 2025, 10:26am UTC](https://discuss.python.org/t/looking-for-feedback-on-adding-import-autocomplete-to-pyrepl/82281/51 "2025-10-27T10:26:19Z")

</div>

I brought up the security concern but I also think we should not overdo it, a second TAB is ok.

“True double-tab” as in double-clicking sounds awkward and unexpected to me (does this even exist in other UIs?), and let’s not start with F8, triple-tabbing or other oddities. 🙂

---

<div class="post-metadata">

**Author:** ![loic-simon](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/loic-simon/32/37461_2.png) [@loic-simon](https://discuss.python.org/u/loic-simon)\
**Post date:** [October 28, 2025, 9:35am UTC](https://discuss.python.org/t/looking-for-feedback-on-adding-import-autocomplete-to-pyrepl/82281/52 "2025-10-28T09:35:25Z")

</div>

All right, thanks all for the feedback! I think we can go with the second TAB then 😃

Before I open a PR, I have a second interrogation: should we make effort to handle modules printing stuff during import gracefully? If you try to autocomplete `from this import `\[1\] in the demo, you’ll see it goes quite messy, but maybe it is rare enough to not bother with it? (exceptions during import are already handled gracefully)

I suppose we could just temporarily catch stdout/stderr and dump their content properly on new lines before re-painting the prompt _(that may be better in a follow-up PR, though?)_

* * *

1. or `from lazy_import demo ` 🤫

---

<div class="post-metadata">

**Author:** ![loic-simon](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/loic-simon/32/37461_2.png) [@loic-simon](https://discuss.python.org/u/loic-simon)\
**Post date:** [December 4, 2025, 7:49pm UTC](https://discuss.python.org/t/looking-for-feedback-on-adding-import-autocomplete-to-pyrepl/82281/53 "2025-12-04T19:49:17Z")

</div>

For anyone interested, my PR implementing auto-complete for attributes has been open for a month now:

- [Issue](https://github.com/python/cpython/issues/140870)
- [PR](https://github.com/python/cpython/pull/140871)
- [WebAssembly demo](https://pyrepl-attributes-import-completion.pages.dev)

There’s still plenty of time, but I’d really love to see this land in 3.15!

---

<div class="post-metadata">

**Author:** ![tomasr8](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/tomasr8/32/11872_2.png) [@tomasr8](https://discuss.python.org/u/tomasr8)\
**Post date:** [December 28, 2025, 11:35am UTC](https://discuss.python.org/t/looking-for-feedback-on-adding-import-autocomplete-to-pyrepl/82281/54 "2025-12-28T11:35:05Z")

</div>

Hey Loïc! Sorry for the late reply, I took a pause from cpython for a while 🙂 I’ll try to review your PR soon. Feel free to ping me if I forget!

---

<div class="post-metadata">

**Author:** ![loic-simon](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/loic-simon/32/37461_2.png) [@loic-simon](https://discuss.python.org/u/loic-simon)\
**Post date:** [January 2, 2026, 4:34pm UTC](https://discuss.python.org/t/looking-for-feedback-on-adding-import-autocomplete-to-pyrepl/82281/55 "2026-01-02T16:34:44Z")

</div>

Update: @tomasr8 suggested that we can automatically import standard library modules, since

- there is no risk of unwanted side-effects\[1\]
- the import time will always be \< a few ms

If anyone think this is not ok, please say so!  
Otherwise you can check the new behavior on [the WebAssembly demo](https://pyrepl-attributes-import-completion.pages.dev/) _(with a little hack, please read the note!)_

* * *

1. except some easter eggs…

---

<div class="post-metadata">

**Author:** ![pf\_moore](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/pf_moore/32/35_2.png) [@pf\_moore](https://discuss.python.org/u/pf_moore)\
**Post date:** [January 2, 2026, 8:25pm UTC](https://discuss.python.org/t/looking-for-feedback-on-adding-import-autocomplete-to-pyrepl/82281/56 "2026-01-02T20:25:25Z")

</div>

> [@loic-simon](#):
>
> there is no risk of unwanted side-effects

Yeah, try “from this import `<TAB>`” for some “unwanted side effects” (or an easter egg, as you call it in the footnote) 🙂

And I notice that “from antigravity import `<TAB>`” says “No module named antigravity”, which may be true in pyodide, but isn’t true in the normal REPL…

I’m not sure this sort of weirdness is OK, TBH, even if it _is_ rare.

---

<div class="post-metadata">

**Author:** ![loic-simon](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/loic-simon/32/37461_2.png) [@loic-simon](https://discuss.python.org/u/loic-simon)\
**Post date:** [January 2, 2026, 8:41pm UTC](https://discuss.python.org/t/looking-for-feedback-on-adding-import-autocomplete-to-pyrepl/82281/57 "2026-01-02T20:41:58Z")

</div>

Yes, `this` and `antigravity` are the two sidlib modules with side effects I’m aware of! But I cannot see why anyone would want to import something from them: these easter eggs are always explained as `import this` / `import antigravity`, which never trigger automatic import.

> [@pf\_moore](#):
>
> And I notice that “from antigravity import `<TAB>`” says “No module named antigravity”, which may be true in pyodide, but isn’t true in the normal REPL…

Note that `antigravity` is _not_ suggested by the REPL (eg. if you type `from anti<TAB>`), precisely because it is not available 😃 the message you’re seeing is the same as if you try `from spam import <TAB>`.

> [@pf\_moore](#):
>
> I’m not sure this sort of weirdness is OK, TBH, even if it _is_ rare.

I can understand this position, even if I thing the QOL benefits largely outweight the costs.

One thing I would like to do though is to capture any text printed on module import, display it cleanly below the prompt, and then the prompt agao, avoiding the ugly mess that `from this import`\[1\] currently is. Would that alleviate your concerns by some measure?

* * *

1. or `from lazy_demo import`…

---

<div class="post-metadata">

**Author:** ![pf\_moore](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/pf_moore/32/35_2.png) [@pf\_moore](https://discuss.python.org/u/pf_moore)\
**Post date:** [January 2, 2026, 9:31pm UTC](https://discuss.python.org/t/looking-for-feedback-on-adding-import-autocomplete-to-pyrepl/82281/58 "2026-01-02T21:31:09Z")

</div>

> [@loic-simon](#):
>
> Yes, `this` and `antigravity` are the two sidlib modules with side effects I’m aware of! But I cannot see why anyone would want to import something from them

Agreed - I’d be fine with just special-casing those two, to be honest. (In the standard REPL, “from antigravity import …” would open the user’s web browser, and that definitely shouldn’t happen, so special-casing is probably the only good option in practice, just to be safe).

> [@loic-simon](#):
>
> One thing I would like to do though is to capture any text printed on module import, display it cleanly below the prompt, and then the prompt agao, avoiding the ugly mess that `from this import` currently is. Would that alleviate your concerns by some measure?

If we’re just talking about stdlib modules, having a policy that they cannot have any side effects without some way to disable those side-effects in autocomplete mode\[1\] is probably better.

If we’re talking about 3rd party modules, output is the least of my concerns. But this has been discussed already, and if the consensus is that it’s OK, then just because I’m personally still not comfortable with the risks, is no reason to rehash everything yet again.

* * *

1. Where “special case the module in autocomplete” is one such option 🙂

---

<div class="post-metadata">

**Author:** ![loic-simon](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/loic-simon/32/37461_2.png) [@loic-simon](https://discuss.python.org/u/loic-simon)\
**Post date:** [January 2, 2026, 11:33pm UTC](https://discuss.python.org/t/looking-for-feedback-on-adding-import-autocomplete-to-pyrepl/82281/59 "2026-01-02T23:33:03Z")

</div>

> [@pf\_moore](#):
>
> having a policy that they cannot have any side effects without some way to disable those side-effects in autocomplete mode is probably better.

Fine by me! I wrote a small script to try and import all stdlib modules / submodules and ran it (on Windows, masOS and WSL) to check for any side effects: in addition of `antigravity` and `this`, I found `idlelib.idle` and a few ` __main__ ` submodules that seem to lack a `if __name__ == " __main__"'` guard; I’m adding them all to a blacklist.

---

<div class="post-metadata">

**Author:** ![brettcannon](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/brettcannon/32/34895_2.png) [@brettcannon](https://discuss.python.org/u/brettcannon)\
**Post date:** [January 7, 2026, 8:18pm UTC](https://discuss.python.org/t/looking-for-feedback-on-adding-import-autocomplete-to-pyrepl/82281/60 "2026-01-07T20:18:17Z")

</div>

> [@loic-simon](#):
>
> I’m adding them all to a blacklist.

There will need to be a test if there’s going to be a blocklist to make sure it’s up-to-date.

[Previous page](https://discuss.python.org/t/looking-for-feedback-on-adding-import-autocomplete-to-pyrepl/82281.md?page=2)

[Next page](https://discuss.python.org/t/looking-for-feedback-on-adding-import-autocomplete-to-pyrepl/82281.md?page=4)
