ty icon indicating copy to clipboard operation
ty copied to clipboard

docstrings and signatures in hovers should fallback to base classes

Open KeepNoob opened this issue 2 months ago • 2 comments

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.

Image

Ty result: Image

And in Pyrefly and Pylance, it also render function signature.

Pyrefly: Image

Version

VS Code Ty extension 2025.74.0

KeepNoob avatar Dec 18 '25 04:12 KeepNoob

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.

Gankra avatar Dec 18 '25 06:12 Gankra

Both pylance and pyrefly render the documentation from the ancestor class Model when hovering a constructor call. But neither render the __doc__ attribute

Image Image

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.

MichaReiser avatar Dec 18 '25 06:12 MichaReiser