jedi Interpreter completion fails for properties












1














I would like to improve the auto-completion in a python console that is part of a project I am working on. While jedi works great for this in general, there is one special case where it fails to find any completion suggestions: Properties of classes defined as methods with the @property decorator.
The following example should explain my problem:



import jedi

class B:
def __init(self):
pass

def see_me(self):
pass

class A:
def __init__(self):
pass

@property
def b(self):
return B()

def get_b(self):
return B()

a = A()

script = jedi.Interpreter('a.b.', [locals()])
comps = script.completions()
print('Interpreter completion (property): ', comps)

script = jedi.Interpreter('a.get_b().', [locals()])
comps = script.completions()
print('Interpreter completion (method): ', comps)


executing the script returns:



Interpreter completion (property):  
Interpreter completion (method): [<Completion: see_me>, ...]


When the method with the @property decorator is called, no completion is found by jedi. The "normal" method works just fine.
Am I using jedi the wrong way here or is this just one of the cases that is too hard to solve for jedi?



Thanks in advance for your help!



PS: I also tried putting the whole code until a = A() into a string and used Script instead of Interpreter to get the completion. Interestingly this was then successful in finding the correct completion also for the @propertydecorated method.










share|improve this question






















  • You're on to something here. Please add an issue in Jedi's issue tracker. I wouldn't say this is a bug, but it's clearly something where Jedi could perform better.
    – Dave Halter
    Dec 2 at 18:33










  • Sure I will add it. Do you know why it works when using "Script" instead of "Interpreter". I tried looking through the source code to find a reason for that (and maybe a simple fix) but couldn't figure it out.
    – Brow 71189
    Dec 4 at 4:01










  • In one case you're giving Jedi actual Python object in the other you give Jedi code (a string). One is basically static analysis, while the other is not, it actually accesses the given Python objects. It's hard to get all information out of Python objects.
    – Dave Halter
    Dec 12 at 15:53
















1














I would like to improve the auto-completion in a python console that is part of a project I am working on. While jedi works great for this in general, there is one special case where it fails to find any completion suggestions: Properties of classes defined as methods with the @property decorator.
The following example should explain my problem:



import jedi

class B:
def __init(self):
pass

def see_me(self):
pass

class A:
def __init__(self):
pass

@property
def b(self):
return B()

def get_b(self):
return B()

a = A()

script = jedi.Interpreter('a.b.', [locals()])
comps = script.completions()
print('Interpreter completion (property): ', comps)

script = jedi.Interpreter('a.get_b().', [locals()])
comps = script.completions()
print('Interpreter completion (method): ', comps)


executing the script returns:



Interpreter completion (property):  
Interpreter completion (method): [<Completion: see_me>, ...]


When the method with the @property decorator is called, no completion is found by jedi. The "normal" method works just fine.
Am I using jedi the wrong way here or is this just one of the cases that is too hard to solve for jedi?



Thanks in advance for your help!



PS: I also tried putting the whole code until a = A() into a string and used Script instead of Interpreter to get the completion. Interestingly this was then successful in finding the correct completion also for the @propertydecorated method.










share|improve this question






















  • You're on to something here. Please add an issue in Jedi's issue tracker. I wouldn't say this is a bug, but it's clearly something where Jedi could perform better.
    – Dave Halter
    Dec 2 at 18:33










  • Sure I will add it. Do you know why it works when using "Script" instead of "Interpreter". I tried looking through the source code to find a reason for that (and maybe a simple fix) but couldn't figure it out.
    – Brow 71189
    Dec 4 at 4:01










  • In one case you're giving Jedi actual Python object in the other you give Jedi code (a string). One is basically static analysis, while the other is not, it actually accesses the given Python objects. It's hard to get all information out of Python objects.
    – Dave Halter
    Dec 12 at 15:53














1












1








1







I would like to improve the auto-completion in a python console that is part of a project I am working on. While jedi works great for this in general, there is one special case where it fails to find any completion suggestions: Properties of classes defined as methods with the @property decorator.
The following example should explain my problem:



import jedi

class B:
def __init(self):
pass

def see_me(self):
pass

class A:
def __init__(self):
pass

@property
def b(self):
return B()

def get_b(self):
return B()

a = A()

script = jedi.Interpreter('a.b.', [locals()])
comps = script.completions()
print('Interpreter completion (property): ', comps)

script = jedi.Interpreter('a.get_b().', [locals()])
comps = script.completions()
print('Interpreter completion (method): ', comps)


executing the script returns:



Interpreter completion (property):  
Interpreter completion (method): [<Completion: see_me>, ...]


When the method with the @property decorator is called, no completion is found by jedi. The "normal" method works just fine.
Am I using jedi the wrong way here or is this just one of the cases that is too hard to solve for jedi?



Thanks in advance for your help!



PS: I also tried putting the whole code until a = A() into a string and used Script instead of Interpreter to get the completion. Interestingly this was then successful in finding the correct completion also for the @propertydecorated method.










share|improve this question













I would like to improve the auto-completion in a python console that is part of a project I am working on. While jedi works great for this in general, there is one special case where it fails to find any completion suggestions: Properties of classes defined as methods with the @property decorator.
The following example should explain my problem:



import jedi

class B:
def __init(self):
pass

def see_me(self):
pass

class A:
def __init__(self):
pass

@property
def b(self):
return B()

def get_b(self):
return B()

a = A()

script = jedi.Interpreter('a.b.', [locals()])
comps = script.completions()
print('Interpreter completion (property): ', comps)

script = jedi.Interpreter('a.get_b().', [locals()])
comps = script.completions()
print('Interpreter completion (method): ', comps)


executing the script returns:



Interpreter completion (property):  
Interpreter completion (method): [<Completion: see_me>, ...]


When the method with the @property decorator is called, no completion is found by jedi. The "normal" method works just fine.
Am I using jedi the wrong way here or is this just one of the cases that is too hard to solve for jedi?



Thanks in advance for your help!



PS: I also tried putting the whole code until a = A() into a string and used Script instead of Interpreter to get the completion. Interestingly this was then successful in finding the correct completion also for the @propertydecorated method.







python-jedi






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 21 at 0:33









Brow 71189

62




62












  • You're on to something here. Please add an issue in Jedi's issue tracker. I wouldn't say this is a bug, but it's clearly something where Jedi could perform better.
    – Dave Halter
    Dec 2 at 18:33










  • Sure I will add it. Do you know why it works when using "Script" instead of "Interpreter". I tried looking through the source code to find a reason for that (and maybe a simple fix) but couldn't figure it out.
    – Brow 71189
    Dec 4 at 4:01










  • In one case you're giving Jedi actual Python object in the other you give Jedi code (a string). One is basically static analysis, while the other is not, it actually accesses the given Python objects. It's hard to get all information out of Python objects.
    – Dave Halter
    Dec 12 at 15:53


















  • You're on to something here. Please add an issue in Jedi's issue tracker. I wouldn't say this is a bug, but it's clearly something where Jedi could perform better.
    – Dave Halter
    Dec 2 at 18:33










  • Sure I will add it. Do you know why it works when using "Script" instead of "Interpreter". I tried looking through the source code to find a reason for that (and maybe a simple fix) but couldn't figure it out.
    – Brow 71189
    Dec 4 at 4:01










  • In one case you're giving Jedi actual Python object in the other you give Jedi code (a string). One is basically static analysis, while the other is not, it actually accesses the given Python objects. It's hard to get all information out of Python objects.
    – Dave Halter
    Dec 12 at 15:53
















You're on to something here. Please add an issue in Jedi's issue tracker. I wouldn't say this is a bug, but it's clearly something where Jedi could perform better.
– Dave Halter
Dec 2 at 18:33




You're on to something here. Please add an issue in Jedi's issue tracker. I wouldn't say this is a bug, but it's clearly something where Jedi could perform better.
– Dave Halter
Dec 2 at 18:33












Sure I will add it. Do you know why it works when using "Script" instead of "Interpreter". I tried looking through the source code to find a reason for that (and maybe a simple fix) but couldn't figure it out.
– Brow 71189
Dec 4 at 4:01




Sure I will add it. Do you know why it works when using "Script" instead of "Interpreter". I tried looking through the source code to find a reason for that (and maybe a simple fix) but couldn't figure it out.
– Brow 71189
Dec 4 at 4:01












In one case you're giving Jedi actual Python object in the other you give Jedi code (a string). One is basically static analysis, while the other is not, it actually accesses the given Python objects. It's hard to get all information out of Python objects.
– Dave Halter
Dec 12 at 15:53




In one case you're giving Jedi actual Python object in the other you give Jedi code (a string). One is basically static analysis, while the other is not, it actually accesses the given Python objects. It's hard to get all information out of Python objects.
– Dave Halter
Dec 12 at 15:53

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53403672%2fjedi-interpreter-completion-fails-for-properties%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53403672%2fjedi-interpreter-completion-fails-for-properties%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

404 Error Contact Form 7 ajax form submitting

How to know if a Active Directory user can login interactively

Refactoring coordinates for Minecraft Pi buildings written in Python