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

generics.complete_object broken #27

Closed
ipython opened this issue May 10, 2010 · 2 comments
Closed

generics.complete_object broken #27

ipython opened this issue May 10, 2010 · 2 comments
Milestone

Comments

@ipython
Copy link
Collaborator

ipython commented May 10, 2010

Original Launchpad bug 527968: https://bugs.launchpad.net/ipython/+bug/527968
Reported by: dsdale24 (Darren Dale).

generics.complete_object appears to be broken in the trunk (0.11alpha). It keeps returning TryNext in situations where it should not. As a result, it is proving to be very difficult to support some custom completers with the forthcoming ipython-0.11:

In [12]: generics.complete_object('foo', dir('foo'))
---------------------------------------------------------------------------
TryNext                                   Traceback (most recent call last)

/Users/darren/Projects/phynx.git/<ipython console> in <module>()

/Users/darren/Projects/ipython/IPython/external/simplegeneric.pyc in dispatch(*args, **kw)
     73                 f = _gbt(t, _sentinel)
     74                 if f is not _sentinel:
---> 75                     return f(*args, **kw)
     76             else:
     77                 return func(*args, **kw)

/Users/darren/Projects/ipython/IPython/utils/generics.pyc in complete_object(obj, prev_completions)
     60     own_attrs + prev_completions.
     61     """
---> 62     raise TryNext
     63
     64

TryNext:
@takluyver
Copy link
Member

It's not clear if the original reporter was attempting to use this correctly. complete_objects is a generic, and should be extended like this:

@generics.complete_object.when_type(MyClass):
def f(myclass_obj, prev_completions):
    return #Stuff from myclass_obj

(there's also a when_object decorator for specific objects)

The TryNext errors are raised when it doesn't find a matching type or object to dispatch to, and appear to be caught in core/completer.py (line 372). So I'm not sure that this is actually a bug.

@fperez
Copy link
Member

fperez commented Mar 23, 2011

I agree with Thomas, closing. This was incorrect usage of the generic, not a bug.

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

No branches or pull requests

2 participants