__all__ feature, improvement to dir2, and tests for both #1529

Merged
merged 5 commits into from Apr 15, 2012

Conversation

Projects
None yet
3 participants
@drtimcouper
Contributor

drtimcouper commented Mar 27, 2012

The 2 patches (relating to __all__ and dir2) are applied, plus the CBool change and a couple of tests to confirm the correct behaviour of complete with, and without, limit_to__all__ being set

drtimcouper added some commits Mar 27, 2012

added __all__ to completer.py and added basic tests for test_dir2
Signed-off-by: Tim Couper <drtimcouper@gmail.com>
Added test_dir2 for the dir2 (bonus) tests
Signed-off-by: Tim Couper <drtimcouper@gmail.com>
Changes to dir2 to remove duplicates fix: put limit_to__all__ default…
… to 0 fix: the doctest to reflect the new limit_to__all__

Signed-off-by: Tim Couper <drtimcouper@gmail.com>
@takluyver

This comment has been minimized.

Show comment
Hide comment
@takluyver

takluyver Mar 27, 2012

Member

N.B. For background, see discussion on PRs #1497 and #1528.

Member

takluyver commented Mar 27, 2012

N.B. For background, see discussion on PRs #1497 and #1528.

@fperez

This comment has been minimized.

Show comment
Hide comment
@fperez

fperez Apr 15, 2012

Member

I've realized that this feature is potentially a bit dangerous, as modules don't always keep their __all__ too well. For example, numpy doesn't list float in __all__, presumably b/c it's a builtin. But this means that with this new feature on, users could be mislead into thinking that numpy.float isn't a valid dtype identifier, since they would see other similar ones but not float itself.

In any case, since the feature is off by default, it won't bite anyone by accident. Advanced users can decide to activate it and it will be their responsibility to be aware of what happens. Furthermore, since it can be easily toggled at runtime with %config, I'm not too worried.

The implementation looks clean, and with good tests, so I'm merging it (after review and also interactive testing). Many thanks for the contribution and the persistence of going through 3 PRs :) And also thanks @takluyver for your diligent work on it!

Member

fperez commented Apr 15, 2012

I've realized that this feature is potentially a bit dangerous, as modules don't always keep their __all__ too well. For example, numpy doesn't list float in __all__, presumably b/c it's a builtin. But this means that with this new feature on, users could be mislead into thinking that numpy.float isn't a valid dtype identifier, since they would see other similar ones but not float itself.

In any case, since the feature is off by default, it won't bite anyone by accident. Advanced users can decide to activate it and it will be their responsibility to be aware of what happens. Furthermore, since it can be easily toggled at runtime with %config, I'm not too worried.

The implementation looks clean, and with good tests, so I'm merging it (after review and also interactive testing). Many thanks for the contribution and the persistence of going through 3 PRs :) And also thanks @takluyver for your diligent work on it!

fperez added a commit that referenced this pull request Apr 15, 2012

Merge pull request #1529 from drtimcouper/master
Implement new configurable flag to control tab completion on modules that implement the __all__ attribute:

IPCompleter.limit_to__all__= Boolean.
Instruct the completer to use __all__ for the completion
Specifically, when completing on ``object.<tab>``.
When True: only those names in obj.__all__ will be included.
When False [default]: the __all__ attribute is ignored.

@fperez fperez merged commit 47367a0 into ipython:master Apr 15, 2012

mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this pull request Nov 3, 2014

Merge pull request #1529 from drtimcouper/master
Implement new configurable flag to control tab completion on modules that implement the __all__ attribute:

IPCompleter.limit_to__all__= Boolean.
Instruct the completer to use __all__ for the completion
Specifically, when completing on ``object.<tab>``.
When True: only those names in obj.__all__ will be included.
When False [default]: the __all__ attribute is ignored.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment