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

Forcibly disable auto-completion on certain objects / attributes of object #11053

Open
SylvainCorlay opened this issue Mar 22, 2018 · 3 comments

Comments

@SylvainCorlay
Copy link
Member

I am using a bunch type to enable auto-completion on keys of a dictionary.

screen shot 2018-03-22 at 4 50 40 pm

I would like to remove anything that is not a key of that dictionary from the results of the auto-completion so that it is not polluted with the methods and attributes of the base dict class.

Is there a means to achieve this?

@takluyver
Copy link
Member

If it's a class you're writing, you can override the __dir__ method which is used to find completions.

@SylvainCorlay
Copy link
Member Author

Thanks! Would this have side effects?

At the moment, I am using traitlets.utils.Bunch. Dunno if it would make sense to override __dir__ on traitlets.utils.Bunch. All of this is fairly cosmetic anyway.

@takluyver
Copy link
Member

I don't think __dir__() is important for anything else, but I'm not 100% sure of that. Possibly in this particular case, a smarter way would be to implement something similar to Bunch that doesn't inherit from dict.

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

2 participants