JuliaPy / JuliaPy/PyCall.jl

shift + tab python function signature

Offen
#454 5 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Julia
Sterne
1.5k
Forks
186
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

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)
```

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.