docstrings and signatures in hovers should fallback to base classes
Summary
Currently, ty only support doc string star with """, but in some case the package author use ___doc___ instead. For example, class Cov2d in Pytorch use __doc__ which could not display within ty.
Ty result:
And in Pyrefly and Pylance, it also render function signature.
Pyrefly:
Version
VS Code Ty extension 2025.74.0
I can't find any evidence of any LSP supporting __doc__, even with completely trivial instances like
class MyClass:
__doc__ = "hello there"
The instances in pytorch are, to put it mildly, nightmarish for static analysis to resolve. They're concatenating and formatting and splatting strings across several files. I expect this is basically always the case for anyone using __doc__ because if you could express it simply, you would have.
I'm not opposed to adding support for __doc__ but I'd want a motivating case that is practical for static analysis to support.
Both pylance and pyrefly render the documentation from the ancestor class Model when hovering a constructor call. But neither render the __doc__ attribute
There are two things we want to investigate here:
- Why is ty not showing the
__init__signature when hovering the constructor call - We should extend ty's docstring detection to walk up the ancestor chain for overridden methods.