rstudio / reticulate

R Interface to Python
https://rstudio.github.io/reticulate
Apache License 2.0
1.68k stars 328 forks source link

argument autocompletion fails for built-in functions #318

Open kevinushey opened 6 years ago

kevinushey commented 6 years ago

For example:

library(reticulate)
np <- import("numpy")
np$arange(<TAB>)

No completion items are returned. More specifically, this fails to return arguments:

reticulate:::help_formals_handler.python.builtin.object("arange", np)

This may ultimately be a limitation of Python. From https://docs.python.org/3.8/library/inspect.html:

Note Some callables may not be introspectable in certain implementations of Python. For example, in CPython, some built-in functions defined in C provide no metadata about their arguments.

For NumPy functions implemented in native code, we could fall back to parsing the parameter documentation for getting the available arguments.

machow commented 6 years ago

Just a quick note--there are a few python projects that have manually documented the signatures of built-ins. For example...

https://github.com/pytoolz/toolz/blob/master/toolz/_signatures.py

https://github.com/datacamp/pythonwhat/blob/master/pythonwhat/signatures.py