[IPython-dev] add tab completion for arguments dynamically
Matthias Bussonnier
bussonniermatthias at gmail.com
Thu Mar 2 16:25:33 EST 2017
Hi Glenn,
You can set the `__signature__` of your object. likely possible with a
decorator.
Here is a short example of how you could do it in a REPL.
In [21]: from inspect import Signature, Parameter
In [22]: def foo(*kwargs):
...: pass
In [23]: foo?
Signature: foo(*kwargs)
Docstring: <no docstring>
File: ~/dev/docathon/<ipython-input-22-086da1400d07>
Type: function
In [24]: foo.__signature__ = Signature(parameters={Parameter('a',
Parameter.POSITIONAL_OR_KEYWORD):None})
In [25]: foo?
Signature: foo(a)
Docstring: <no docstring>
File: ~/dev/docathon/<ipython-input-22-086da1400d07>
Type: function
That should not only work with IPython, but with anything that use
the Python inspect library.
Note that what I do above is imperfect as you should use an
OrderedDict instead of a dict for `parameters=...`
Does that helps ?
--
M
On Thu, Mar 2, 2017 at 12:58 PM, G Jones <glenn.caltech at gmail.com> wrote:
> Hi,
> Is it possible to customize the completion list when typing keyword
> arguments?
> For example suppose I have a function like:
> def myfunc(**kwargs):
> val = kwargs['val']
>
> is there a way to tell ipython that when it sees me type:
> myfunc(va<tab>
>
> it suggests "val="?
>
> Thanks,
> Glenn
>
>
>
> _______________________________________________
> IPython-dev mailing list
> IPython-dev at scipy.org
> https://mail.scipy.org/mailman/listinfo/ipython-dev
>
More information about the IPython-dev
mailing list