Search code examples
pythonjedi-vim

Get return type of a suggested function in Jedi


I'm trying to improve the way python completions are displayed with YouCompleteMe (which uses Jedi). Currently it just shows the completion, and the "full path":

capitalize          function: __builtin__.str.capitalize
center              function: __builtin__.str.center
count               function: __builtin__.str.count

Ideally, I'd like it to show the signature and the inferred return type for functions (like you have with C/C++ completions).

Is there a way to get from a jedi.api.classes.Completion object (which represents a function) to that function's return type?

Jedi has that information somewhere, since if you call that function and complete on it, obj.function().|, it knows what type function returns and offers correct completions.


Solution

  • There is currently no such API. Such an API would definitely be possible, but note that sometimes those types are different depending on what your params are (it's not Java).

    Just add an issue on Github to discuss this: https://github.com/davidhalter/jedi/issues

    This is not a big thing to implement, it's much more about how the API looks.