-
-
Notifications
You must be signed in to change notification settings - Fork 511
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Autocomplete inherited methods when overriding in child class #458
Comments
Hmm, this could potentially be another method of #253. I'm not sure if this should be part of the autocompletion (by default). But there could be some kind of switch to enable this. |
Sorry for bumping old thread, but feature described by topicstarter would be very useful. |
@Nahtrezer |
Done! |
Please note that you need to use Jedi's |
How to use this feature? I'm using jedi v0.11.1 through jedi-vim, but not autocompleted. I checked commit
I'm currently asking the same question in stackoverflow. Envirionment
|
I do not think this is possible as of now. 647a4db appears to be only about parent methods, but not args itself. |
Is there any possible solution for this right now? |
About what? |
Auto-completing the child method of an overriding class while using jedi. I'm using VS code BTW |
Not exactly sure what you mean with that.
That should work. At least it does for me. (v0.13.3+). |
Like suggesting params for the method
Not working for me maybe because i'm writing the method from parent of the current parent class |
Please open an issue if you want that. This was about something else.
That doesn't work and probably won't for quite some time. It's also a bad idea IMO in many cases and in the few cases where it's a good idea, it's probably easy enough to remember. If you want a solution for this, use |
I think the issue of method override completion with parameters is still not resolved. I've searched online but it seems nobody is talking about it. Take test file test/completion/context.py in 647a4db for example: As I mentioned in 647a4db#r150509859, an ideal completion with parameter in line 13 should be #? ['func(self, foo)']
def f EditedI've checked the implementation of However, the problem I'm trying to solve goes as follows: When calling a class method, only completing the name like this is OK: #? ['func']
X().f This is because I can see the parameter declaration after typing the left parenthesis # Method declaration hint will popup with `func(foo)` here
X().func( However, this feature doesn't exist with method override. Therefore, it'll be hard to follow the parent class method declaration for complex methods. Not sure how to solve the problem, but I guess it's not Jedi's job. |
Jedi just doesn't do that yet, but I wouldn't oppose pull requests into this direction, if it's well done. |
From an issue from Anaconda:
When working with frameworks, a very common pattern is to inherit from a provided class and then overriding the class methods/fields to customize behavior.
When writing this new customized child class, a very helpful tool is the autocomplete-functionality of both the method that I'm trying to override and also the autocompletion of the required arguments. This functionality is provided in IDEs like PyCharm and PyDev.
Example
A dropdown should appear here with a suggestion to autocomplete to
save
, and writing a left parenthesis should then generate all the parameters:Maybe an autocompletion to
super(TestModel, self).save(...)
would be better, or not generating the super call at all would also be acceptable (though preferably it should be generated), but this is the behavior in the Eclipse plugin PyDev (a dropdown is generated in which you can choose the option:save (Override method in models.Model)
when pressing the autocomplete keybindingCTRL + Space
)I.e. my suggestion is to make Jedi aware of a cursor being inside a (child) class that is inheriting from another (parent) class, and when trying to override methods and fields (defined in the parent class) from within the child class, Jedi should autocomplete the fields and methods and also their arguments.
The text was updated successfully, but these errors were encountered: