[IPython-dev] function specific tab completion via annotations

Robert McGibbon rmcgibbo at gmail.com
Tue Dec 18 03:03:33 EST 2012


It's not working in the notebook with the argument specific completions, but the return value completion is working. There must be some issue with a difference in the line splitting with readline and without. I'll track it down.

-Robert

On Dec 17, 2012, at 11:51 PM, Brian Granger wrote:

> This looks really great.  Have you tested it with the notebook yet?  I
> would imagine that it should already work there as well.
> 
> On Mon, Dec 17, 2012 at 11:27 PM, Robert McGibbon <rmcgibbo at gmail.com> wrote:
>> Hey,
>> 
>> I just posted a new PR for annotation based custom tab completion.
>> https://github.com/ipython/ipython/pull/2701
>> 
>> The code is fairly complex (~1000 new lines), so I assume that there are
>> bugs. For that reason (and because its fun!), I encourage people
>> to try taking it out for a spin.
>> 
>> 
>> It lets you do things like this:
>> 
>> In [1]: from IPython.extensions.completion import tab_complete, globs_to,
>> literal
>> 
>> In [2]: @tab_complete
>>  ...: def baz(x) -> str:
>>  ...:     pass
>>  ...:
>> 
>> In [3]: baz(notevaluated).<TAB>
>> .capitalize  .find        .isspace     .partition   .rstrip      .translate
>> .center      .format      .istitle     .replace     .split       .upper
>> .count       .index       .isupper     .rfind       .splitlines  .zfill
>> .decode      .isalnum     .join        .rindex      .startswith
>> .encode      .isalpha     .ljust       .rjust       .strip
>> .endswith    .isdigit     .lower       .rpartition  .swapcase
>> .expandtabs  .islower     .lstrip      .rsplit      .title
>> 
>> 
>> And this:
>> 
>> In [4]: @tab_complete
>>   ...: def foo(x : globs_to('*.txt'), mode : literal('r', 'w')):
>>   ...:     pass
>>   ...:
>> 
>> In [5]: foo(<TAB>
>> 'COPYING.txt'        'dist/'              'setupext/'
>> 'IPython/'           'docs/'              'tools/'
>> '__pycache__/'       'ipython.egg-info/'
>> 'build/'             'scripts/'
>> 
>> In[6]: foo('COPYING.txt', <TAB>
>> 'r', 'w'
>> 
>> 
>> 
>> -Robert
>> 
>> _______________________________________________
>> IPython-dev mailing list
>> IPython-dev at scipy.org
>> http://mail.scipy.org/mailman/listinfo/ipython-dev
>> 
> 
> 
> 
> -- 
> Brian E. Granger
> Cal Poly State University, San Luis Obispo
> bgranger at calpoly.edu and ellisonbg at gmail.com
> _______________________________________________
> IPython-dev mailing list
> IPython-dev at scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-dev




More information about the IPython-dev mailing list