JuliaPy / JuliaPy/PyCall.jl

shift + tab python function signature

Open
#454 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
Julia
Stars
1.5k
Forks
186
PR merge metrics
No merged PRs in 30d

Description

This was something I was missing when working with my python code, specifically interactively in the Jupyter notebook.

I don't know how to implement this in a safe way so I'll propose it here as an enhancement. Basically, on shift + tab we should grab the python function signature like IPython does in the Jupyter Notebook.

```julia
@pyimport IPython.core.oinspect as oinspect
function pyobjsignature(o::PyObject)
s = oinspect.signature(o)[:__str__]()
if haskey(o, "__name__")
s = string(o["__name__"][:__str__](), s)
else
s = string("function_call -> ", s)
end
if haskey(o, "__doc__")
d = o[:__doc__]
end
if typeof(d) <: AbstractString
return Base.Docs.Text(join([s, convert(AbstractString, d)], "\n"))
else
return Base.Docs.Text(join([s, "No Python Docstring"], "\n"))
end
end
Base.Docs.getdoc(o::PyObject) = pyobjsignature(o)
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.