You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I am developing tab completion feature for a Python library and have found jedi to be quite useful. My use case is to detect the class name of the object on which completion was requested. Is there a clean way to achieve this? I could find below workaround, here the goal is to find that x is of type Z.
fromjediimportInterpreterclassZ:
deffoo(self): passcode="""x = Z()x."""interpreter=Interpreter(code, [locals()])
completions=interpreter.complete(line=3, column=2)
foo=completions[0].full_name# completion for function foo, full name is '__main__.Z.foo'class_name='.'.join(foo.split('.')[:-1])
class_name
Thanks!
The text was updated successfully, but these errors were encountered:
Does completions[0].parent().full_name work for you?
Thanks for the reply!! Yes, this works.
But, actually I was looking for a way to this without calling interpreter.complete. I would like to explain my use-case a bit more -
I want to show custom completions only on objects which are of a certain class (say Z in this case), I want to determine statically if x is of type Z - the workaround I am using is putting a method foo on Z and checking if foo comes when I complete x.. This doesn't scale well though. Happy to know if there some solutions around this in jedi.
Hi, I am developing tab completion feature for a Python library and have found
jedi
to be quite useful. My use case is to detect the class name of the object on which completion was requested. Is there a clean way to achieve this? I could find below workaround, here the goal is to find thatx
is of typeZ
.Thanks!
The text was updated successfully, but these errors were encountered: