-
Notifications
You must be signed in to change notification settings - Fork 768
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
Correctly resolve collections(.abc)
class/method Definition to source file instead of typing.py or typeshed-fallback
#6316
Comments
The completion suggestion functionality in pyright is maintained by the pylance team. Could someone from the pylance team please transfer this feature request to the pylance-release project and triage it as you see fit? Thanks! |
I'm not sure this move was correct. I just tested with the "Pyright" extension (while Pylance is uninstalled) and it has the exact same issues. This is also not about "completion suggestion" at all... its about the "Find Definitions to quickly go to the location of a symbol’s definition" and "Hover over symbols to provide type information and doc strings" features listed here https://microsoft.github.io/pyright/#/features?id=language-server-support Unless the pyright language server should also have issues reported in pylance-release? |
as for repro, not sure how to provide one... from collections.abc import MutableMapping
MutableMapping.get and then hover over |
Pyright is focused on type checking functionality. It offers some basic language server features, but these are maintained by the pylance team. In general, any bugs or feature requests related to language server features get moved to the pylance-release project, and any bugs or feature requests related to type checking features get moved to the pyright project. |
the issue is our code that finds matching ex) probably need to add special case to handle these cases. |
@heejaechang i'm thinking maybe go to definition should resolve the alias and never go to 'MutableMapping = _alias(collections.abc.MutableMapping, 2)' line. for instance go to def on np in 'np.array' goes to the numpy's 'init.py' import numpy as np
arr = np.array([1, 2, 3]) a special case for '_alias' ? |
Is your feature request related to a problem? Please describe.
Currently, Pyright resolves the Definition of types like
collections.abc.MutableMapping
as their alias assignment line intyping.py
.For methods like
MutableMapping.pop
it seems to resolve the Definition totypeshed-fallback
instead, showing a list of overloads.There are also currently no docstrings for
collections.abc
classes and their methods.Describe the solution you’d like
As this is a relatively common and core part of type-hinting and part of stdlib, I'd really like custom behaviour here which can find the correct Definition in
collections(.abc)
which contains the actual implementation of these types or base classes.This likely would require some custom behaviour for typing._SpecialGenericAlias which makes Pyright consider it more akin to a type alias.
Ideally, "Go to Definition" would show the actual source code of how something is implemented.
"Go to Declaration" could then show the typing.py alias line, and only "Go to Type Definition" would end up in typeshed-fallback.
At the same time, this should allow docstrings for these types to be resolved properly.
(Note: This was observed in both the latest release Pylance in vscode or latest release Pyright in vscode with Python 3.12.5 on Windows, but has existed across multiple machines and combinations of versions, which is why i assume this is not a bug but just a missing feature)
The text was updated successfully, but these errors were encountered: