-
-
Notifications
You must be signed in to change notification settings - Fork 33.8k
gh-140870: PyREPL auto-complete module attributes in import statements #140871
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?
gh-140870: PyREPL auto-complete module attributes in import statements #140871
Conversation
Could you extract those into a separate PR? I think those are nice to have in any case and we can merge it quickly :) |
Sure, #143244 |
|
Quick initial question, can we disable the prompt for stdlib modules? I don't think there should be any concerns with auto-importing from the stdlib |
|
We could, yes. I don't think we can decide to auto-import solely on module name (to take care of potential shadowing by first/third-party modules), so we would need to look the module spec location, but since we already have (I'll won't be to get my hands on the code until early January tho) |
|
Yup, we definitely need to look at the module location, not just the name |
Add the ability for
_pyrepl._module_completer.ModuleCompleterto suggest attributes, in addition to modules.If the module to import from is not imported yet, ask the user if they want to import it.
This is done by adding the notion of completion action to
_pyrepl.completing_reader.CompletingReader:get_completionscan return a completion action, in addtion to the suggestions listget_completionsis called again, so it can propose new results (here, module attributes)Other changes:
_module_completerto 100% (in a separate commit, I can remove it if needed)Interactive WebAssembly demo (up to date): https://pyrepl-attributes-import-completion.pages.dev
Possible improvement (probably in a follow-up PR): make modules printing stuff when imported not mess with the prompt ; see this Discourse message