-
Notifications
You must be signed in to change notification settings - Fork 1.5k
[ty] Make initializer calls GotoTargets #20014
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
Conversation
Diagnostic diff on typing conformance testsNo changes detected when running ty on typing conformance tests ✅ |
|
Pyright jumps to the definition of the class. I'm leaning towards aligning the behavior for now (although it is somewhat unexpected, so maybe what you have is best) |
Something I've vaguely been considering is another variant of DefinitionsOrTargets that has two lists of definitions: one is the "right" answer and one is "fallback". So docstrings would consider both but goto-def would be opinionated and just pick one? |
1b55209
to
4361794
Compare
Surprisingly a lot of reports of different IDEs actually making the |
4361794
to
0959fd4
Compare
This sounds nice |
ca6e9ee
to
2a43d29
Compare
Ok I've rebased this on top of #20148 and minimized its intelligence, making this a reasonably safe change. I'm going to land this now (feedback is the best way to iterate on exact UX of this I think). |
This introduces `GotoTarget::Call` that represents the kind of ambiguous/overloaded click of a callable-being-called: ```py x = mymodule.MyClass(1, 2) ^^^^^^^ ``` This is equivalent to `GotoTarget::Expression` for the same span but enriched with information about the actual callable implementation. That is, if you click on `MyClass` in `MyClass()` it is *both* a reference to the class and to the initializer of the class. Therefore it would be ideal for goto-* and docstrings to be some intelligent merging of both the class and the initializer. In particular the callable-implementation (initializer) is prioritized over the callable-itself (class) so when showing docstrings we will preferentially show the docs of the initializer if it exists, and then fallback to the docs of the class. For goto-definition/goto-declaration we will yield both the class and the initializer, requiring you to pick which you want (this is perhaps needlessly pedantic but...). Fixes astral-sh/ty#898 Fixes astral-sh/ty#1010
This introduces `GotoTarget::Call` that represents the kind of ambiguous/overloaded click of a callable-being-called: ```py x = mymodule.MyClass(1, 2) ^^^^^^^ ``` This is equivalent to `GotoTarget::Expression` for the same span but enriched with information about the actual callable implementation. That is, if you click on `MyClass` in `MyClass()` it is *both* a reference to the class and to the initializer of the class. Therefore it would be ideal for goto-* and docstrings to be some intelligent merging of both the class and the initializer. In particular the callable-implementation (initializer) is prioritized over the callable-itself (class) so when showing docstrings we will preferentially show the docs of the initializer if it exists, and then fallback to the docs of the class. For goto-definition/goto-declaration we will yield both the class and the initializer, requiring you to pick which you want (this is perhaps needlessly pedantic but...). Fixes astral-sh/ty#898 Fixes astral-sh/ty#1010
This introduces
GotoTarget::Call
that represents the kind of ambiguous/overloaded click of a callable-being-called:This is equivalent to
GotoTarget::Expression
for the same span but enrichedwith information about the actual callable implementation.
That is, if you click on
MyClass
inMyClass()
it is both areference to the class and to the initializer of the class. Therefore
it would be ideal for goto-* and docstrings to be some intelligent
merging of both the class and the initializer.
In particular the callable-implementation (initializer) is prioritized over the callable-itself (class) so when showing docstrings we will preferentially show the docs of the initializer if it exists, and then fallback to the docs of the class.
For goto-definition/goto-declaration we will yield both the class and the initializer, requiring you to pick which you want (this is perhaps needlessly pedantic but...).
Fixes astral-sh/ty#898
Fixes astral-sh/ty#1010