generics.py 706 B

1234567891011121314151617181920212223242526272829
  1. # encoding: utf-8
  2. """Generic functions for extending IPython.
  3. """
  4. from IPython.core.error import TryNext
  5. from functools import singledispatch
  6. @singledispatch
  7. def inspect_object(obj):
  8. """Called when you do obj?"""
  9. raise TryNext
  10. @singledispatch
  11. def complete_object(obj, prev_completions):
  12. """Custom completer dispatching for python objects.
  13. Parameters
  14. ----------
  15. obj : object
  16. The object to complete.
  17. prev_completions : list
  18. List of attributes discovered so far.
  19. This should return the list of attributes in obj. If you only wish to
  20. add to the attributes already discovered normally, return
  21. own_attrs + prev_completions.
  22. """
  23. raise TryNext