Skip to content
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

Support REPL import completion (needs investigation first) #128786

Closed
2 tasks
kfatyuip opened this issue Jan 13, 2025 · 7 comments
Closed
2 tasks

Support REPL import completion (needs investigation first) #128786

kfatyuip opened this issue Jan 13, 2025 · 7 comments
Labels
stdlib Python modules in the Lib dir topic-repl Related to the interactive shell type-feature A feature request or enhancement

Comments

@kfatyuip
Copy link

kfatyuip commented Jan 13, 2025

Feature or enhancement

Proposal:

press TAB after

import o

shows

object()  oct(      open(     or        ord(

Has this already been discussed elsewhere?

No response given

Links to previous discussion of this feature:

No response

Tasks

Preview Give feedback
@kfatyuip kfatyuip added the type-feature A feature request or enhancement label Jan 13, 2025
@picnixz picnixz added topic-repl Related to the interactive shell stdlib Python modules in the Lib dir labels Jan 13, 2025
@picnixz
Copy link
Member

picnixz commented Jan 13, 2025

I'd be glad to have this but I'm afraid it will be inefficient. It's possible to autocomplete attributes because the namespace already exists at runtime. However, if one writes import x, we need to discover all modules that start with x (and those in site-packages!) and that's probably a no-go.

cc @pablogsal

@pablogsal
Copy link
Member

I'd be glad to have this but I'm afraid it will be inefficient. It's possible to autocomplete attributes because the namespace already exists at runtime. However, if one writes import x, we need to discover all modules that start with x (and those in site-packages!) and that's probably a no-go.

cc @pablogsal

This is the case but is not unheard of. For example, IPython (and many other REPL) does it:

https://github.com/ipython/ipython/blob/364e544a76c590ff161d9fffacf35533db478324/IPython/core/completerlib.py#L108-L152

We could profile it and if we see is not too bad we can try to add support for it

@picnixz
Copy link
Member

picnixz commented Jan 13, 2025

Maybe we could also make this feature on demand? that way we wouldn't penalize current users if they don't need that feature. But I would definitely be interested in knowing whether it's feasible for us or not (and would be happy to review such PR if we find a good solution)

@pablogsal
Copy link
Member

Maybe we could also make this feature on demand? that way we wouldn't penalize current users if they don't need that feature. But I would definitely be interested in knowing whether it's feasible for us or not (and would be happy to review such PR if we find a good solution)

We should first benchmark to know what is the cost. My guess is that is close to be negligible. We can also try to back off if there are too many packages or add some other stopgaps to control the impact

@picnixz picnixz changed the title add import completion for interactive mode Support REPL import completion (needs investigation first) Jan 13, 2025
@picnixz
Copy link
Member

picnixz commented Jan 13, 2025

I've added two tasks for users that want to work on that. We need a PoC first and it's better for anyone wanting to help NOT to create any PR first but link their own fork in this issue as well as their results. We'll decide on how to proceed afterwards.

@vadmium
Copy link
Member

vadmium commented Jan 13, 2025

See #69605 for my attempt ten years ago

@picnixz
Copy link
Member

picnixz commented Jan 13, 2025

Oh there was a precedent. Maybe it's better to close this issue then (it seems the IPython case was also mentioned in the original issue).

EDIT: Considering that #117312 was closed as duplicate, I'll also close this one as a duplicate.

@picnixz picnixz closed this as not planned Won't fix, can't repro, duplicate, stale Jan 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir topic-repl Related to the interactive shell type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

4 participants