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

Tab completion fails on regular imports when using InteractiveShellEmbed #6921

Closed
clebio opened this issue Nov 13, 2014 · 2 comments
Closed
Milestone

Comments

@clebio
Copy link

clebio commented Nov 13, 2014

Using IPython.terminal.embed.InteractiveShellEmbed as an embedded, interactive shell, I cannot get regular importing to tab-complete. Once a package (say netrc) is imported, I can still tab-complete the package, though.

To wit, create a test file sheller.py:

from cli.app import CommandLineApp
from IPython.terminal.embed import InteractiveShellEmbed


class Manager(CommandLineApp):

    def setup(self):
        super(Manager, self).setup()
        self.intro_message = 'Context manager running'

    def main(self):
        ipshell = InteractiveShellEmbed()
        ipshell.banner2 = self.intro_message
        ipshell(global_ns=dict(), local_ns=dict())
        logging.info("Interactive shell closed.")

if __name__ == "__main__":
    Manager().run()

Then, from Bash, run it:

$ python sheller.py
Python 2.7.2 (default, Oct 11 2012, 20:14:37)
Type "copyright", "credits" or "license" for more information.

IPython 1.1.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

Context manager running
In : import net<tab> # ...crickets...

In : import netrc # explicit import, not tabbing
In : netrc.<tab>
netrc.NetrcParseError  netrc.netrc            netrc.os               netrc.shlex
In : quit

$ ipython
Python 2.7.2 (default, Oct 11 2012, 20:14:37)
Type "copyright", "credits" or "license" for more information.

IPython 1.1.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In : import net<tab>rc
In : import netrc

This appears to be related to the following issues:

@olaurino
Copy link

I had a similar issue with InteractiveShell and I am going to open an issue for that.

However, I tested my fix against your code, and it seems to work for your issue as well (the underlying issue is probably the same).

In main, change the way you instantiate InteractiveShellEmbed as follows:

ipshell = InteractiveShellEmbed.instance()

I tested this on Linux with different versions of IPython 1.x and 2.x.

@clebio
Copy link
Author

clebio commented Nov 25, 2014

Aweome sauce! That fixes it. Confirmed on OSX 10.8.5, IPython 2.3.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants