Skip to content

Advanced import completion#844

Closed
etiennerichart wants to merge 9 commits intobpython:masterfrom
etiennerichart:advanced-import-completion
Closed

Advanced import completion#844
etiennerichart wants to merge 9 commits intobpython:masterfrom
etiennerichart:advanced-import-completion

Conversation

@etiennerichart
Copy link
Copy Markdown
Contributor

when typed: from import <> and tab is pressed will background import the module to get better autocomplete options. Note: If nothing is yet typed after the import the autocomplete will not show any options.

@sebastinas
Copy link
Copy Markdown
Contributor

I'm not sure what this PR tries to achieve. What's the behavior before and after this change?

@thomasballinger
Copy link
Copy Markdown
Member

The goal of this PR is that when typing out an import for a module (numpy for example)
>>> from numpy import a<tab> should display all submodules and module attributes. Hitting tab might cause numpy to be imported too.

I don't know the status of this PR, it's been on my list to review for a bit; I worked with @etiennerichart on it but haven't been paying attention for a couple months now.

@sebastinas
Copy link
Copy Markdown
Contributor

Ah, yes, that's indeed useful.

@sebastinas sebastinas added this to the New features milestone Oct 11, 2020
@sebastinas
Copy link
Copy Markdown
Contributor

We just removed 0.20 to fix compatibility with Python 3.9 and now dropped support for Python 2 in master. The latter touched almost the whole code base. Could you please rebase this PR on top of current master? Thanks

return attr_matches(name, prefix="", only_modules=True)


def try_to_import(module_name):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this really necessary? Shouldn't those modules already be found by our normal module processing routines?

@etiennerichart etiennerichart force-pushed the advanced-import-completion branch from 1d22675 to 4ebd9bc Compare October 19, 2020 19:22
@etiennerichart
Copy link
Copy Markdown
Contributor Author

I have not been able to test functionality yet since I'm having trouble starting bpython on my PC. I'm getting the following error:
File "c:\users\etien\appdata\local\programs\python\python38-32\lib\site-packages\blessings\__init__.py", line 5, in <module> import curses File "c:\users\etien\appdata\local\programs\python\python38-32\lib\curses\__init__.py", line 13, in <module> from _curses import * ModuleNotFoundError: No module named '_curses'
If someone wants to test it for me, just try:
from <module> import <at least one letter> seeing if there are autocomplete suggestions, then pressing tab to see if you get more suggestions. I usually test on using numpy module but you may have to pip install it.

@sebastinas
Copy link
Copy Markdown
Contributor

As far as I can tell, the PR works as expected. I'm just not sure if we need the additional module discovery code.

@sebastinas sebastinas modified the milestones: New features, release-0.21 Oct 24, 2020
@sebastinas
Copy link
Copy Markdown
Contributor

Okay, I took a look at this PR again. I don't think we should merge it in its current state. from x import y auto completion is already in handled in bpython.importcompletion and bpython.autocomplete. The issue that this PR tries to solve is auto completion when our import completion hasn't processed x. What we could discuss if we can fix the import completion code to process x in bpython.importcompletion.complete if it is not yet known.

But I don't think we should add a curtsies specific workaround that breaks abstraction.

sebastinas added a commit that referenced this pull request Jan 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants