vxgmichel / aiostream

Generator-based operators for asynchronous iteration
http://aiostream.readthedocs.io
GNU General Public License v3.0
793 stars 34 forks source link

Docstring and prototype not properly shown with pylance #109

Open vxgmichel opened 5 months ago

vxgmichel commented 5 months ago

Pylance does not show the actual docstring and prototype when overing a stream operators: stream

Surprisingly, it does show it for their pipe method: pipe

Also, it does show when opening a parenthesis after a stream operator: stream2

Note that introspection does work properly:


$ ipython
In [1]: from aiostream import stream
In [2]: stream.take?
Signature:      stream.take(source: 'AsyncIterable[T]', n: 'int') -> 'Stream[T]'
Type:           PipableOperatorImplementation
String form:    aiostream.stream.select.take
File:           ~/repos/aiostream/aiostream/stream/select.py
Docstring:     
Forward the first ``n`` elements from an asynchronous sequence.

If ``n`` is negative, it simply terminates before iterating the source.
vxgmichel commented 5 months ago

Interestingly, that issue has been addressed on the pylance tracker last week: https://github.com/microsoft/pylance-release/issues/5840#issuecomment-2089378623

In summary, I think the pyright type analyzer is doing the right thing here and preserving the docstring, but the hover provider (which is owned by the pylance team) is not using this information when the identifier is an instance of a callable object (i.e. an instance of a class that has a __call__ method). So I think this is a feature request for the Pylance team to add such support.

It seems like this will be fixed in the future.