-
Notifications
You must be signed in to change notification settings - Fork 767
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
Goto definition goes to stub files instead of actual definitions #65
Comments
Duplicate microsoft/pyright#795 |
Goto definition on Goto definition on |
As a suggestion, if you couldn't control the order of displayed results, it would be nice to have an option turn off displaying |
@jahan01 Thanks for the suggestion. We're looking into solutions and will update here soon. |
Could we have two separate commands like
|
At the moment, that is expected behavior. |
I am trying to annotate tqdm. So I did the following:
from typing import Any, Generic, Iterable, Iterator, TypeVar
T = TypeVar('T')
class tqdm(Generic[T]):
def __init__(self, iterable: Iterable[T], *args: Any, **kwargs: Any): ...
def __iter__(self) -> Iterator[T]: ...
Now when I click on tqdm -> "Go to Definition" on another piece of code (like `from tqdm import tqdm') it jumps straight to the stub file. Also if I try to see the references on "Go to References" the source code is not listed (it was before adding the stub file). Selecting Peek -> "Peek Definition" only display the stub file as well. I would expect it to show the source code (or at least give an option to it) when clicking "Go to Definition" |
This is a major bug. Navigation into stdlib and 3rd party libraries is basically broken. |
Anybody thought there is an ambiguous meaning between |
Well alright. Thanks @jakebailey . I was looking thoroughly but didn't use the word "stub" just For me this is simply broken atm and it was fine in the past. I mean I wanna be fair here: You're doing awesome work already and when doing progress things need to break here and there but I'd at least wanna know how to backup. |
That default preference for pyi drives me insane as it is killing the entire code browsing experience for any library that happens to keep type hints outside the source files. I do not want to browse the stubs when the source files exist and we clearly need and option to tell it to respect that preference. Our only luck is that very few libraries decided to put keep type hints in pyi files. |
This is a sound solution, your rarely are interested in definition or type stubs at the same time.
|
My C/++ years precede the existence of vscode so I do not know what is current behavior on Cmd+click as I would wish to be Go To Definition by default. There is a slight issue with having two options because what if you do not have a definition and you only have access to the declaration? in that case I suppose it should send you to the only one available Apparently the UI is bit confused about what is a definition and declaration as I right click on the method and choose "Go To Definition" and instead it opens the in-line preview of the declaration: |
Also having trouble with this. Previously i at least got both the stub and implementation, but now I only get the stub when using F12... |
I am also experiencing this issue. My current solution involves renaming my |
Started happening to me today. No workaround for this at least? |
We are currently investigating solutions to address this. |
For the meantime I've downgraded pylance extension to v2020.11.1 . It now shows the documentation properly and a click will follow to the source. Unfortunately, I don't exactly know which version broke the behaviour, therefore I just tried an older version. Hope I don't have to use the older version for long, as some people are already working to resolve this issue. Update: unfortunately, the mentioned version is also not working after restarting vscode, sorry for confusion.. |
Seems there are already some related issues: #844, #170 ? Or would you rather have another one dedicated to build-in libs? |
The next release includes a change to go-to-definition's behavior and adds go-to-declaration. Go-to-definition prefers source files, while go-to-declaration prefers stubs. Here's an example jumping to If either of these calls would otherwise return no results (e.g. go-to-def when only a stub is available), then the old behavior is used so that you don't mysteriously jump nowhere. |
This issue has been fixed in version 2021.2.1, which we've just released. You can find the changelog here: https://github.com/microsoft/pylance-release/blob/main/CHANGELOG.md#202121-10-february-2021 |
For me is not fixed. Example:
If I try Go to Definition or Go to Declaration for attrgetter, both goes to stub file. |
Not fixed for me either. For me it fails with the following: from django.urls import include, path It correctly takes me to the source of |
Whow! I thought it was working! But obviously not always import pipes
pipes.quote() Ctrl+Clicking |
Please report these as individual bugs. We won't be reopening this issue for every case, as the primary functionality for filtering the results is in place. Not being able to jump to certain files or going to the wrong place are different issues and existed before this was fixed. (This fix is just a filter over previous results.) |
This still jumps me to the stubs most of the time on v2021.2.3, especially in Django projects. |
Please file a new issue for those cases, but you may want to wait for the next release, which includes a good number of improvements to the way we map stubs to their source files. |
This issue should not have been closed before some testing, not after getting this feedback |
@andrewmed if you open new issue with repro step specific to your issue, we can take a look. "go to definition" can go to stub instead of actual definition due to million different reasons. this issue is for some specific reasons which we added logic to handle. if it didn't work for you, yours is probably due to different reasons we don't know about yet. but without repro steps, we can't even take a look. |
this major issue exsist now . Not solved yet. so inconvenient. Hope it will be solved as soon as possible! pylance _v2022.1.1 Version: 1.63.2 (user setup) |
@zakigo, as heejaechang mentioned above, we need repro steps to understand what you are seeing. Please file a new issue with repro steps for what you are seeing. |
I have encountered the same issue. In the past, I could at least see .pyi files and the source code. However, now, no matter which one I use between 'Go to Definition,' 'Go to Declaration,' and 'Go to Type Definition,' I can only see .pyi files (located in .vscode-server/extensions/ms-python.vscode-pylance-2023.10.20/dist/typeshed-fallback/stdlib). My Pylance version is 2023.10.20. |
@olivarius1, please file a new issue. The issue that you are commenting on was fixed 2.5 years ago and is likely unrelated to what you are seeing. |
For python 3.8.10, with pylance v2023.1.10 #!/usr/bin/python3
import sys
from unicodedata import category
|
Where would you expect it to take you in this case? There is no |
Expected behaviour
Goto definition goes to actual code even if types are defined in a stub file
Actual behaviour
Goto definition goes to stub files instead of actual code
Code Snippet / Additional information
Try goto definition (F12) on either
HTTPStatus
in line 1 orGATEWAY_TIMEOUT
in line 3The text was updated successfully, but these errors were encountered: