-
-
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
Go to method definition in Python modules fails with "No definition found for '<method_name>'" message #1402
Comments
Hey @karrtikr Thanks for the detailed report. I quickly copied the files here, because I don't have VScode and it's easier to reason about them here: app.py
Test/test.py
|
Thanks for the detailed report. I assume PyCharm only works when
is used in Nested folder structures are a bit of an issue in Jedi sometimes. I'm definitely keeping your use case in mind when I'm tackling #1059. So don't expect a quick fix, it might take a while (a few months to years), but I'm trying to work on it. |
@marius-nicolae originally reported that issue, but from the screenshot it is evident that no matter if In our case we only point to the definitions if function is called (which is probably better). But I think the enhancement is in case when we have multiple function calls, we should have a pop up of both definitions instead of going to the first one. @marius-nicolae You can correct me if that's not what you asked for. |
If the full code is provided (without comments), Jedi lists both definition. I feel like this was VScode's decision to jump to the first one. For me with jedi-vim, it shows two definitions. However this only happens if you uncomment all the code. |
I see, maybe |
The idea is that often a developer will have to browse a lot of Python code, including modules, where there are many classes methods and functions exposed without calls with actual objects or calls which covers only partially all the possibilities (i.e. in our example, only a test.CallFoo(a) or test.CallFoo(b) would be present). There will be a negative user experience if go to the method definition fails but it's found through grep (i.e. find in files). I would say that, in case the object type can't be determined at a particular point (no method call with an actual object, no types hinting, etc), simply display all the method definitions from all classes available at that point, as currently PyCharm appears to do. I find it much more powerful this way. I also do agree that the information exposed shouldn't be too verbose (all the time) and for cases like:
or when there were type hints ( in our case the function would have been declared as def CallFoo(obj: A):) the go to method definition would go stright to the class method implementation (i.e. in A class, in our example). |
This example is working now. See also my comment in #1047 (comment). This only works under some circumstances.
So if you want this to work 99% of the time and not just 90%, subscribe to #1059. @marius-nicolae I still consider random completions without type inference to be pretty bad. But I'm not generally against having an optional feature that people can use (I don't have to use it, but others can of course). If you want that, please open a new issue and describe how exactly you imagine it, with a few examples. That way it's easy to write tests that make your use case possible. I would also be very interested in a detailed description of how pycharm does it, if you like it. |
Possible enhancement
@marius-nicolae commented on Sat Sep 14 2019
Hi,
First of all, thank you, for your wonderful work. I like VS Code a lot but there is an issue I'd like to report.
Usually, in Python modules, there are classes definitions with methods references but without calls with actual types. In this case, when trying to go to a method definition the VS Code displays a "No definition found for '<method_name>'" message as opposed to Pycharm which displays a menu with all possible methods definitions. Even if the Python file contains calls with actual objects the VS Code will go the first definition even if there are multiple possibilities.
Environment data
Version: 1.38.1
Commit: b37e54c98e1a74ba89e03073e5a3761284e3ffb0
Date: 2019-09-11T13:30:08.229Z
Electron: 4.2.10
Chrome: 69.0.3497.128
Node.js: 10.11.0
V8: 6.9.427.31-electron.0
OS: Linux x64 4.15.0-58-generic
"python.jediEnabled"
set to; more info #3977): Jedi enabledExpected behaviour
VS Code should display a menu with all possible method definitions, with the ones defined in the current .py file on top
Actual behaviour
Displays a "No definition found for '<method_name>'" message in case no calls with actual objects are found in the current file or goes to the first implementation otherwise
Steps to reproduce:
More details, on the attached animated gif.
![Go to method definition-2019-09-14 11-13](https://user-images.githubusercontent.com/28258950/64905958-416e1180-d6e8-11e9-9af5-ea0ef287932d.gif)
The text was updated successfully, but these errors were encountered: