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
…inition Previously, we would include the class definition in addition to the `__init__` and `__new__` methods, if present. But it seems that this generally leads to unintuitive behavior from the perspective of users. It's also not what pyright does. This was also discussed a bit in the PR adding this functionality: #20014. Fixes astral-sh/ty#2218, Ref astral-sh/ty#2639
…inition Previously, we would include the class definition in addition to the `__init__` and `__new__` methods, if present. But it seems that this generally leads to unintuitive behavior from the perspective of users. It's also not what pyright does. This was also discussed a bit in the PR adding this functionality: #20014. Fixes astral-sh/ty#2218, Ref astral-sh/ty#2639
…inition Previously, we would include the class definition in addition to the `__init__` and `__new__` methods, if present. But it seems that this generally leads to unintuitive behavior from the perspective of users. It's also not what pyright does. This was also discussed a bit in the PR adding this functionality: #20014. Fixes astral-sh/ty#2218, Ref astral-sh/ty#2639
…inition Previously, we would include the class definition in addition to the `__init__` and `__new__` methods, if present. But it seems that this generally leads to unintuitive behavior from the perspective of users. It's also not what pyright does. This was also discussed a bit in the PR adding this functionality: #20014. Fixes astral-sh/ty#2218, Ref astral-sh/ty#2639
…inition Previously, we would include the class definition in addition to the `__init__` and `__new__` methods, if present. But it seems that this generally leads to unintuitive behavior from the perspective of users. It's also not what pyright does. This was also discussed a bit in the PR adding this functionality: #20014. Fixes astral-sh/ty#2218, Ref astral-sh/ty#2639
This introduces
GotoTarget::Callthat represents the kind of ambiguous/overloaded click of a callable-being-called:This is equivalent to
GotoTarget::Expressionfor the same span but enrichedwith information about the actual callable implementation.
That is, if you click on
MyClassinMyClass()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